Skip to content

fix: resolve REST Ingestion 400 INVALID_ARGUMENT and CLI runtime initialization - #60

Merged
dandye merged 15 commits into
mainfrom
issue_59_v0001
Sep 14, 2026
Merged

dandye merged 15 commits into
mainfrom
issue_59_v0001

Conversation

@dandye

@dandye dandye commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Resolves #59 by fixing payload formatting and regional endpoint resolution for the Chronicle REST API ingestion backend, enabling CLI parameter validation for --project-id, adding lazy runtime backend initialization, and bundling default workshop usecases.

Changes

  1. Regional URL Resolution: Updated Chronicle REST regional endpoints and parent resource paths (_get_resolved_region() and _get_parent()) to route multi-region US and Europe instances to us-chronicle.googleapis.com and europe-chronicle.googleapis.com.
  2. CLI Parameter Validation: Added get_project_id_default() and updated _load_and_validate_params() to validate --project-id from CLI options without requiring environment variables.
  3. Timestamp Formatting: Enforced RFC 3339 UTC timestamps with Z suffix (%Y-%m-%dT%H:%M:%S.%fZ) on event_timestamp, log_entry_time, and collection_time.
  4. Entity Payload Schema: Aligned with ImportEntitiesRequest by placing log_type at the root of inline_source rather than inside individual entity objects.
  5. Forwarder Handling: Supported HTTP 200/201 on forwarder creation and safely omitted "forwarder" from inline_source when creation or lookup fails.
  6. CLI Runtime Initialization: Implemented get_ingestion_backend() lazy loading in main.py and ensured cache invalidation when CLI arguments or .env variables are loaded.
  7. Graceful Entity Skip: Gracefully skip with exit code 0 and an informative message when --entities is specified for a usecase that has no entity logs.
  8. Bundled Usecases: Bundled EDR_WORKSHOP, HIGH_RISK_USER_DOWNLOAD_EXECUTABLE_FROM_MACRO, and MALWARE_IOC in src/logstory/usecases/.

Closes #59

…tion (Issue #59)

- Fix parameter validation in logstory.py to accept and validate CLI --project-id
  even when LOGSTORY_PROJECT_ID environment variable is unset.
- Add get_project_id_default helper and pass resolved project ID to environment.
- Correct REST_REGION_NAME_MAP so us and europe map to multi-region endpoints
  us and europe rather than regional locations that return 404.
- Add _get_parent and _get_resolved_region helpers on RestIngestionBackend to
  ensure API endpoint and parent resource locations match.
- Safely handle forwarder resolution in _get_or_create_forwarder by returning None
  instead of invalid 'default' string, omitting forwarder from inline_source.
- Format ingestion timestamps using RFC 3339 UTC with Z suffix (%Y-%m-%dT%H:%M:%S.%fZ).
- Fix ImportEntitiesRequest payload structure by placing log_type on inline_source
  rather than inside each entity dictionary.
- Update and expand unit test suites in test_cli.py and test_ingestion.py.
… replay (Issue #59)

TAG=agy
CONV=db7f5985-4477-42a8-8f7f-11c7b558f9eb
TAG=agy
CONV=db7f5985-4477-42a8-8f7f-11c7b558f9eb
#59)

TAG=agy
CONV=db7f5985-4477-42a8-8f7f-11c7b558f9eb
…usecases

TAG=agy
CONV=db7f5985-4477-42a8-8f7f-11c7b558f9eb
TAG=agy
CONV=db7f5985-4477-42a8-8f7f-11c7b558f9eb
Allow usecase log files under src/logstory/usecases/ to be tracked in git
and included in package distributions.

TAG=agy
CONV=db7f5985-4477-42a8-8f7f-11c7b558f9eb
… import (Issue #59)

The SecOps REST entities:import endpoint expects Entity proto objects
which do not have a top-level labels field.

TAG=agy
CONV=db7f5985-4477-42a8-8f7f-11c7b558f9eb
…layout

Revert commits 2a1d9e2, 623b53a, and 5c276d9. Usecases will be fetched
from configured storage buckets instead of being bundled in the package.

TAG=agy
CONV=db7f5985-4477-42a8-8f7f-11c7b558f9eb
When authenticated client encounters credentials or refresh errors,
fall back to anonymous GCS client to allow downloading public usecases.

TAG=agy
CONV=db7f5985-4477-42a8-8f7f-11c7b558f9eb
…count credentials for GCS

TAG=agy
CONV=db7f5985-4477-42a8-8f7f-11c7b558f9eb
…credentials

TAG=agy
CONV=db7f5985-4477-42a8-8f7f-11c7b558f9eb
@dandye
dandye merged commit 7cd32b9 into main Sep 14, 2026
19 checks passed
@dandye
dandye deleted the issue_59_v0001 branch September 14, 2026 14:24
@dandye
dandye restored the issue_59_v0001 branch September 14, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: REST Ingestion fails with 400 INVALID_ARGUMENT (ImportLogs failed)

1 participant