`ingest_log` sends local wall-clock time labelled as UTC by default, and raises TypeError for timezone-aware `log_entry_time`
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 76/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- python
- Domínio
- backend-api-design
Direção de pesquisa
Comece lendo ingest_log() e o tratamento de timestamps, incluindo os valores padrão, a verificação da ordem e a formatação descritos na issue. Compare o comportamento com get_alerts, que, segundo a issue, lida com datetimes naive e com fuso horário. Atualize o tratamento de UTC para valores padrão e entradas com fuso horário e, em seguida, verifique os valores padrão e a ordem com um transporte simulado em fusos horários UTC e não UTC.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 94
- Forks
- 49
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de google/secops-wrapper
-
Use warning logging instead of stderr print for HTTP retriesTalvez já em andamento @MatufA assumiu há 110 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
google/secops-wrapper#221 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
google/secops-wrapper#213 · 1 comentário ·
-
bug(chronicle): nl_search and search_udm drop :udmSearch stats payload and misreport 0 resultsTalvez já em andamento @dandye assumiu há 11 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
google/secops-wrapper#227 ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 48/100
google/secops-wrapper#224 ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 62/100
google/secops-wrapper#223 · 1 comentário ·
Todas as issues de google/secops-wrapper
Issues semelhantes
-
bug good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
aws-samples/sample-spec-driven-presentation-maker#648 ·
Mantenedores costumam responder em até 1 dia
-
firestore: enable live window.yaml pipeline system tests once add_window_fields is in productionAberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 64/100
googleapis/google-cloud-python#19115 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
Mantenedores costumam responder em até 3 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Feyisara2108/stellargive#1377 ·
Mantenedores costumam responder em até 1 dia
-
CRS WKT default to WKT2Abertaenhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 1 dia