bug(chronicle): nl_search and search_udm drop :udmSearch stats payload and misreport 0 results
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- python
- Bereich
- backend-api-design
Rechercherichtung
Start with src/secops/chronicle/search.py and src/secops/chronicle/stats.py, then check the nl_search caller in src/secops/chronicle/nl_search.py and the CLI path in src/secops/cli/commands/search.py. Compare the :udmSearch response handling with ChronicleClient.get_stats and find the existing tests for both event and stats responses. Done means stats queries retain normalized rows and pagination status while plain event queries and as_list=True keep their stated behavior; pull request #228 is already open.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
ChronicleClient.nl_search in src/secops/chronicle/nl_search.py and ChronicleClient.search_udm in src/secops/chronicle/search.py discard result["stats"] from GET /v1alpha/{instance}:udmSearch responses and report total_events: 0 even when matching security telemetry exists.
At the Chronicle REST API layer, :udmSearch handles both plain UDM event filter queries and Chronicle SIEM YARA-L 2.0 statistical queries containing match: and outcome: sections:
- Plain event filter queries populate
eventsand omitstats. - YARA-L 2.0 statistical queries with an
outcome:aggregation section return HTTP 200, populatestats, and omitevents.
Because src/secops/chronicle/search.py reads only result.get("events", []), two data-loss bugs affect shipped SDK and CLI entry points today:
- Natural language search in
client.nl_searchandsecops search --nl-query. When a caller runs an aggregation prompt in plain English such as"Count failed user logins by user in the last 24 hours", Chronicle's:translateUdmQueryendpoint emits a YARA-L 2.0match:andoutcome:query. Bothnl_searchinsrc/secops/chronicle/nl_search.pylines 89 through 99 andhandle_search_commandinsrc/secops/cli/commands/search.pylines 142 through 149 pass that translated query directly toclient.search_udm(...).secops statshas no--nl-queryflag.:udmSearchreturns HTTP 200 withresult["stats"], yetsearch_udmdrops the payload and returns{"events": [], "total_events": 0, "more_data_available": False}, producing a false-negative result during investigations. - Direct
client.search_udmandsecops search --querycalls onoutcome:queries. Passing the query returned byclient.translate_nl_to_udm(...)intoclient.search_udm(...)as shown inREADME.mdalso hits:udmSearch, receives HTTP 200 withstats, and drops every returned row while reportingtotal_events: 0.
Steps to reproduce
from datetime import datetime, timedelta, timezone
from secops import SecOpsClient
CUSTOMER_ID = "<CUSTOMER_ID>"
PROJECT_ID = "<PROJECT_ID>"
REGION = "us"
end_time = datetime.now(timezone.utc)
start_time = end_time - timedelta(hours=24)
sdk = SecOpsClient()
chronicle = sdk.chronicle(
customer_id=CUSTOMER_ID,
project_id=PROJECT_ID,
region=REGION,
)
result = chronicle.nl_search(
text="Count failed user logins by user in the last 24 hours",
start_time=start_time,
end_time=end_time,
)
# :translateUdmQuery emits a YARA-L 2.0 match:/outcome: query and :udmSearch
# returns HTTP 200 with non-empty result["stats"], yet nl_search returns:
# {"events": [], "total_events": 0, "more_data_available": False}
Or from the CLI:
secops search --nl-query "Count failed user logins by user in the last 24 hours" --time-window 24
Expected behavior
When as_list=False and :udmSearch returns a stats dictionary, search_udm keeps its existing keys and attaches normalized stats via process_stats_results from src/secops/chronicle/stats.py so nl_search and search_udm stop losing HTTP 200 response data:
response["stats"]matches thecolumns,rows, andtotal_rowsdictionary structure returned byChronicleClient.get_stats.more_data_availablereflectsresult.get("moreDataAvailable", False)orresult["stats"].get("tooManyResults", False).
Backward compatibility
A fix for this bug is backward compatible across all existing SDK and CLI callers:
- No signature changes.
search_udm,nl_search,get_stats, andsecops searchkeep identical parameters, defaults, and return types. - Plain UDM event filter queries unchanged. Responses without
statscontinue returning the exact 3-key dictionary{"events": [...], "total_events": int, "more_data_available": bool}with nostatskey added. as_list=Trueunchanged. Callers requestingas_list=Truecontinue receivinglist[dict[str, Any]].- Additive
statskey onoutcome:queries. Existing top-level keysevents,total_events, andmore_data_availableremain present with identical types, whilestatsis purely additive and matchesChronicleClient.get_stats1:1. ChronicleClient.get_statsunchanged. Direct statistical query callers see zero behavioral change.
Maintenance mode scope
This is a backward-compatible bug and stability fix for HTTP 200 response data loss and false-negative zero-result output in existing nl_search, search_udm, and secops search --nl-query code paths. It adds no new endpoints, methods, parameters, or dependencies.
- Vorherrschende Sprache
- Python
- Sterne
- 94
- Forks
- 49
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus google/secops-wrapper
-
`ingest_log` sends local wall-clock time labelled as UTC by default, and raises TypeError for timezone-aware `log_entry_time`Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
google/secops-wrapper#229 ·
-
Use warning logging instead of stderr print for HTTP retriesEvtl. vergeben @MatufA hat das vor 110 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
google/secops-wrapper#221 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
google/secops-wrapper#213 · 1 Kommentar ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
google/secops-wrapper#224 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 62/100
google/secops-wrapper#223 · 1 Kommentar ·
Alle Issues in google/secops-wrapper
Ähnliche Issues
-
bug good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
aws-samples/sample-spec-driven-presentation-maker#648 ·
Maintainer antworten meist innerhalb von 1 Tag
-
firestore: enable live window.yaml pipeline system tests once add_window_fields is in productionOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 64/100
googleapis/google-cloud-python#19115 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
CRS WKT default to WKT2Offenenhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag