fix(secops): standardize ISO datetime parsing and normalize to UTC - #292
Open
dandye wants to merge 1 commit into
Open
fix(secops): standardize ISO datetime parsing and normalize to UTC#292dandye wants to merge 1 commit into
dandye wants to merge 1 commit into
Conversation
- Add parse_iso_datetime in secops_mcp.utils to handle trailing Z/z, non-UTC offsets, and naive timestamps with UTC normalization
- Refactor log_ingestion, curated_rules_management, and security_rules to use parse_iso_datetime instead of fragile .replace("Z", "+00:00")
- Add unit tests for timezone offsets, Z/z handling, and error cases
Fixes #291
dandye
force-pushed
the
fix/issue-291-datetime-parsing
branch
from
August 30, 2026 02:42
413a018 to
852d8c3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves issue #291 by replacing the fragile ad-hoc
datetime.fromisoformat(ts.replace("Z", "+00:00"))pattern across SecOps tools with a robust, standardizedparse_iso_datetime()utility.Fixes #291
Changes Made
server/secops/secops_mcp/utils.py:parse_iso_datetime(time_input)supporting bothstranddatetimeinputs."Z"/"z"and explicit non-UTC offsets (e.g."-05:00","+02:00"), guaranteeing conversion to UTC with.astimezone(timezone.utc)so downstream SDK calls like.strftime("%Y-%m-%dT%H:%M:%S.%fZ")send the true UTC timestamp rather than shifted local wall-clock hours.tzinfo=timezone.utc).parse_time_range()to useparse_iso_datetime().Tools Refactored:
server/secops/secops_mcp/tools/log_ingestion.py:ingest_raw_logserver/secops/secops_mcp/tools/curated_rules_management.py:search_curated_detectionsserver/secops/secops_mcp/tools/security_rules.py:create_retrohunt,search_rule_alertsTesting:
tests/test_secops_tools_unit.pycovering uppercase"Z", lowercase"z", non-UTC timezone offsets, naive timestamps, and malformed inputs.