`ingest_log` sends local wall-clock time labelled as UTC by default, and raises TypeError for timezone-aware `log_entry_time`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Bắt đầu bằng cách đọc ingest_log() và cách hàm này xử lý dấu thời gian, bao gồm các giá trị mặc định, kiểm tra thứ tự và định dạng được mô tả trong issue. So sánh hành vi của hàm với get_alerts, được issue dẫn ra là xử lý các datetime naive và có múi giờ. Cập nhật cách xử lý UTC cho các giá trị mặc định và đầu vào có múi giờ, sau đó xác minh giá trị mặc định và thứ tự bằng transport được mô phỏng trong các múi giờ UTC và không phải UTC.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 94
- Fork
- 49
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google/secops-wrapper
-
Use warning logging instead of stderr print for HTTP retriesCó thể đã có người làm @MatufA đã nhận 110 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
google/secops-wrapper#221 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
google/secops-wrapper#213 · 1 bình luận ·
-
bug(chronicle): nl_search and search_udm drop :udmSearch stats payload and misreport 0 resultsCó thể đã có người làm @dandye đã nhận 11 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
google/secops-wrapper#227 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
google/secops-wrapper#224 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
google/secops-wrapper#223 · 1 bình luận ·
Tất cả issue của google/secops-wrapper
Issue tương tự
-
Feature Request
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 68/100
spotDL/spotify-downloader#2839 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Missing license fileĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
ops/setup.py writes ops/hub.json non-atomically (the torn-write class of #219, in the installer)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
mattabate/life-distributable#230 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement triage:not-checked
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
inventree/InvenTree#13318 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Viox-Development/Artificial-Logic-and-Intelligence-Computation-Engine#251 ·
Maintainer thường phản hồi trong vòng 1 ngày