Skip to content

API Reference parrot_tools.s3.report_reader

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.s3.report_reader

View source

S3ReportReaderToolkit — LLM-facing agnostic S3 report reader.

Exposes 8 agent tools (s3_ prefix) for reading, filtering, comparing, and summarizing S3-stored reports. Operates in dual mode:

  • With SecurityReportStore: catalog-backed queries for indexed reports.
  • Without SecurityReportStore: raw S3 browsing via FileManagerInterface only (catalog-dependent tools return an informative error dict).

Module implements Spec §3 Module 1 (FEAT-184).

Alias AbstractToolkit

Re-exported from parrot_tools.toolkit.AbstractToolkit.

Alias GenericReportComparator

Re-exported from parrot_tools.s3.comparator.GenericReportComparator.

Class S3ReportReaderToolkit

Agnostic read-only toolkit for LLM agents to explore S3-stored reports.

Mounts 8 tools with the s3_ prefix, preventing collision when co-mounted with SecurityReportToolkit.

Works in two modes:

  • Full mode (report_store provided): catalog-backed queries available in addition to raw S3 browsing.
  • File-only mode (no report_store): only s3_list_reports, s3_get_report_content, s3_compare_reports, s3_summarize_report, and s3_get_report_url work. Catalog-dependent tools return {"error": "...", "hint": "..."}.
Parameter Type Default Description
file_manager FileManagerInterface Required. Provides raw S3 operations (list, download, URL generation).
report_store SecurityReportStore | None None Optional. Provides catalog-backed queries.
default_prefix str 'security-reports/' S3 key prefix used when prefix is omitted from list_reports. Defaults to "security-reports/".
max_diff_changes int 50 Cap on the changes list returned by compare_reports. Defaults to 50.
**kwargs {} Forwarded to AbstractToolkit.__init__.

Attributes:

Attribute Type Description
tool_prefix str
DEFAULT_VISIBILITY_DAYS int

Method S3ReportReaderToolkit.list_reports

List S3 objects under the given prefix. Works without catalog.

Browses raw S3 objects without using the catalog. Useful for discovering reports that may not be indexed.

list_reports(prefix: str = '', pattern: str = '*.json', limit: int = 50) -> list[dict]

Parameter Type Default Description
prefix str '' S3 key prefix to list under. Defaults to the toolkit's default_prefix ("security-reports/").
pattern str '*.json' Glob pattern to filter results (e.g., "*.json"). Defaults to "*.json".
limit int 50 Maximum number of results to return. Defaults to 50.

Returns: list[dict] — List of file metadata dicts with keys: name, path, size, content_type, modified_at.

Method S3ReportReaderToolkit.get_latest_report

Requires catalog. Return the most recent report matching the filters.

Returns the latest ReportRef metadata from the catalog for the given scanner/framework/kind combination.

get_latest_report(scanner: str | None = None, framework: str | None = None, report_kind: str = 'scan') -> dict

Parameter Type Default Description
scanner str | None None Scanner name (e.g., "cloudsploit", "trivy"). None matches any scanner.
framework str | None None Compliance framework (e.g., "HIPAA"). None matches any framework.
report_kind str 'scan' Report kind — one of "scan", "daily_summary", "weekly_summary", "monthly_summary", "drift_comparison". Defaults to "scan".

Returns: dict — Report metadata dict, or {"error": "..."} if no catalog is configured or no match is found.

Method S3ReportReaderToolkit.get_report_content

Works without catalog (S3 path) or with catalog (UUID).

Fetch and return report content. Accepts either a catalog UUID or a raw S3 key path.

  • UUID ("3fa85f64-5717-4562-b3fc-2c963f66afa6"): fetches content via catalog + applies parser for section extraction.
  • S3 path ("security-reports/cloudsploit/scan.json"): downloads via FileManagerInterface. Scanner is inferred from the path convention {prefix}{scanner}/{framework}/....

For section="full", the entire parsed JSON is returned. For other sections, the registered parser's extract_section is called when a scanner is known. HTML content is always returned as-is (no JSON parsing).

get_report_content(report_id_or_path: str, section: str = 'full') -> dict

Parameter Type Default Description
report_id_or_path str Catalog UUID string or S3 key path.
section str 'full' Section to extract. "full" returns all content. Other values ("summary", "critical", etc.) use the scanner's parser. Defaults to "full".

Returns: dict — Content dict. Returns {"error": "..."} if UUID not found.

Method S3ReportReaderToolkit.filter_reports

Requires catalog. Query the catalog with multiple filters.

Returns a list of report metadata records matching all specified criteria, ordered by produced_at descending.

filter_reports(scanner: str | None = None, framework: str | None = None, provider: str | None = None, report_kind: str | None = None, since_days: int = 30, limit: int = 20) -> list[dict]

Parameter Type Default Description
scanner str | None None Filter by scanner name. None matches all.
framework str | None None Filter by compliance framework. None matches all.
provider str | None None Filter by cloud provider (e.g., "aws"). None matches all.
report_kind str | None None Report kind filter. None matches all kinds.
since_days int 30 Look back at most this many days. Defaults to 30.
limit int 20 Maximum results to return (1–500). Defaults to 20.

Returns: list[dict] — List of ReportRef metadata dicts, or [{"error": "..."}] when no catalog is configured.

Method S3ReportReaderToolkit.compare_reports

Works without catalog (S3 paths) or with catalog (UUIDs).

Diff two report documents and return a structured comparison.

Both arguments can be catalog UUIDs or S3 key paths. Attempts scanner-aware comparison (e.g., CloudSploit domain diff) when the scanner is known; falls back to generic structural JSON diff.

compare_reports(report_a: str, report_b: str) -> dict

Parameter Type Default Description
report_a str UUID or S3 path of the baseline (earlier) report.
report_b str UUID or S3 path of the current (later) report.

Returns: dict — Structured diff dict from GenericReportComparator.compare.

Method S3ReportReaderToolkit.summarize_report

Works without catalog (S3 paths) or with catalog (UUIDs).

Extract structured metrics from a report — no LLM call.

Returns severity breakdown, top findings (from catalog when available), content type, scanner, framework, and detected categories. The calling agent's LLM should generate narrative from this structured output.

summarize_report(report_id_or_path: str) -> dict

Parameter Type Default Description
report_id_or_path str Catalog UUID string or S3 key path.

Returns: dict — Structured metrics dict.

Method S3ReportReaderToolkit.get_report_url

Works without catalog. Generate a pre-signed URL for a report.

Resolves the S3 URI (from catalog if UUID is given, or directly from the path) and generates a pre-signed URL.

get_report_url(report_id_or_path: str, expiry: int = 3600) -> dict

Parameter Type Default Description
report_id_or_path str Catalog UUID string or S3 key path.
expiry int 3600 URL expiry time in seconds. Defaults to 3600 (1 hour).

Returns: dict — Dict with url, path, and expiry_seconds.

Method S3ReportReaderToolkit.list_report_categories

Requires catalog. List distinct scanners, frameworks, and report kinds.

Returns the distinct values present in the catalog for each categorical dimension. Useful for discovering what data is available before using filter_reports.

For scanners: deduplicates via a broad query (limit 500) in Python, since the store only provides query_distinct_frameworks.

list_report_categories() -> dict

Returns: dict — Dict with scanners, frameworks, and report_kinds, or {"error": "..."} when no catalog is configured.

Alias get_report_parser

Re-exported from parrot_tools.security.parsers.get_report_parser.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally