How chronicle/cli works
Project type and purpose
• This is a Python-based command-line interface (CLI) tool.
• Purpose: allow users to manage Chronicle Security Operations resources (Feeds, Parsers, Forwarders, BigQuery access, etc.) by calling Google Chronicle REST APIs.
Main components
• CLI Entry Point (main.py / console script “chronicle_cli”)
• Command Dispatcher / Parser (handles subcommands)
• Domain Modules:
• Feeds
• Parsers
• Forwarders
• Tools (BigQuery, access)
• Common Utilities:
• Authentication (chronicle_auth)
• API Utility (HTTP request builder, retry, error handling)
• Command-line option parsing / templates / constants
• External Services:
• Chronicle Security Operations REST APIs
• (BigQuery API for tools module)
• Local Credentials Store (.chronicle_cli/chronicle_credentials.json)
Relationships and data flow
1. User runs “chronicle_cli <domain> <action> [flags]”.
2. Entry point (main.py) invokes the command dispatcher.
3. Dispatcher loads the appropriate domain module (e.g., feeds/commands/create.py).
4. Domain command calls into Common Utilities:
– chronicle_auth to fetch/refresh OAuth token from credentials file
– api_utility to build and send HTTP request
– file_utility or templates for payload or output formatting
5. HTTP client hits Google Chronicle REST endpoint.
6. Response is returned through api_utility back to the command, which formats output to console.
Key architectural patterns / principles
• Modularization by domain (Feeds, Parsers, Forwarders, Tools)
• DRY common library for authentication, HTTP, constants, and templating
• Single process CLI with sub-command dispatch (flat structure, not microservices)
• Clear separation of concerns:
• Domain logic in each “<domain>/commands”
• Shared HTTP and auth in “common”
• Tests co-located alongside modules