`ingest_log` sends local wall-clock time labelled as UTC by default, and raises TypeError for timezone-aware `log_entry_time`
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
首先阅读 ingest_log() 及其时间戳处理方式,包括 issue 中描述的默认值、顺序检查和格式化。将其行为与 get_alerts 进行比较;issue 指出该函数会处理 naive 和带时区的 datetime。更新默认值和带时区输入的 UTC 处理方式,然后使用模拟的 transport,在 UTC 和非 UTC 时区中验证默认值和顺序。
由索引模型根据 Issue 内容生成。
描述
Summary
ingest_log() (and therefore secops log ingest in the CLI, which never passes timestamps) builds its default log_entry_time / collection_time from datetime.now(), which is a naive local time, and then formats it with a literal Z suffix:
now = datetime.now()
...
log_entry_time_str = log_entry_time.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
On any machine whose local timezone is not UTC, every ingested log gets timestamps shifted by the local UTC offset. In addition, passing a timezone-aware log_entry_time while leaving collection_time at its default raises TypeError: can't compare offset-naive and offset-aware datetimes, independent of the local timezone.
The Chronicle logs.import reference defines both fields as RFC 3339 timestamps ("Z-normalized"), and states that collectionTime "Must be after the logEntryTime".
Reproduction (mocked transport, no credentials)
The probe calls ingest_log(client, "OKTA", ["{}"], force_log_type=True) with chronicle_request patched, then compares the log_entry_time that was sent with datetime.now(timezone.utc):
| local TZ | sent log_entry_time vs real UTC now |
|---|---|
UTC |
+0.0 h |
Europe/Berlin |
+1.0 h (in the future) |
America/Los_Angeles |
-8.0 h |
Same probe, ingest_log(..., log_entry_time=datetime.now(timezone.utc) - timedelta(minutes=5)) with no collection_time:
TypeError: can't compare offset-naive and offset-aware datetimes
(raised in all three timezones).
Expected
Defaults should be the current UTC time, and timezone-aware inputs should be converted to UTC before the ordering check and formatting. This is how get_alerts already handles its time range since #35 (naive -> UTC, aware -> astimezone(timezone.utc)).
Environment
secops at ca553eb (main), Python 3.12, macOS arm64. The behaviour comes from datetime.now() semantics, so it is not platform-specific.
Related: the same "format with a literal Z without converting" pattern exists in other modules (for example search_udm / get_stats send 09:00:00Z for a 09:00+01:00 input), but this issue is limited to ingest_log, where it triggers on the default path.
This issue was drafted with Claude Code (claude-opus-5-5); the results above are from the runs described.
- 主要语言
- Python
- 星标
- 94
- 派生
- 49
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
google/secops-wrapper 的其他 Issue
-
Use warning logging instead of stderr print for HTTP retries可能已有人在做 @MatufA 于 110 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
google/secops-wrapper#221 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
google/secops-wrapper#213 · 1 条评论 ·
-
bug(chronicle): nl_search and search_udm drop :udmSearch stats payload and misreport 0 results可能已有人在做 @dandye 于 11 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
google/secops-wrapper#227 ·
-
难度 3/5 1-2 天 新手友好度 48/100
google/secops-wrapper#224 ·
-
难度 3/5 1-2 天 新手友好度 62/100
google/secops-wrapper#223 · 1 条评论 ·
查看 google/secops-wrapper 的全部 Issue
相似的 Issue
-
Feature Request
难度 1/5 1-3 小时 新手友好度 68/100
spotDL/spotify-downloader#2839 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
-
ops/setup.py writes ops/hub.json non-atomically (the torn-write class of #219, in the installer)未关闭
难度 2/5 1-3 小时 新手友好度 79/100
mattabate/life-distributable#230 ·
维护者通常 1 天内回复
-
enhancement triage:not-checked
难度 2/5 1-3 小时 新手友好度 66/100
inventree/InvenTree#13318 · 1 个 reaction ·
维护者通常 1 天内回复
-
agent good first issue
难度 2/5 1-3 小时 新手友好度 86/100
Viox-Development/Artificial-Logic-and-Intelligence-Computation-Engine#251 ·
维护者通常 1 天内回复