Skip to content

API Reference parrot_tools.security.report_toolkit

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

parrot_tools.security.report_toolkit

View source

SecurityReportToolkit — LLM-facing read side of the security report catalog.

This toolkit exposes the catalog to the LLM as agent tools. The agent calls these tools BEFORE running expensive scanners, guided by the freshness policy in the SecurityAgent BACKSTORY.

Module implements Spec §3 Module 7.

Alias AbstractToolkit

Re-exported from parrot_tools.toolkit.AbstractToolkit.

Class SecurityReportToolkit

LLM-facing tools for querying the cross-session security report catalog.

These tools cover the read side of the catalog. The write side is handled by ReportPersistenceMixin (TASK-1109) composited into each scanner toolkit.

Usage pattern (agent BACKSTORY instructs this flow)::

1. find_security_report(...)  → check if a fresh report exists
2. read_security_report(id, "summary")  → assess severity
3. read_security_report(id, "critical")  → get critical details
4. (only if stale / absent) → run scanner toolkit
Parameter Type Default Description
report_store SecurityReportStore Catalog persistence backend.
file_manager FileManagerInterface File manager for content downloads.
**kwargs {} Additional arguments forwarded to AbstractToolkit.

Attributes:

Attribute Type Description
DEFAULT_VISIBILITY_DAYS int

Method SecurityReportToolkit.find_security_report

Find recent security reports matching the filter criteria.

Returns metadata only (severity summary + top-10 embedded findings). Does NOT fetch or download full report content.

Freshness policy: Always call this BEFORE running expensive scan tools. If a report exists that is fresh enough (within max_age_days), use read_security_report to read its details instead of re-scanning.

find_security_report(scanner: str | None = None, framework: str | None = None, provider: str | None = None, scope_match: dict | None = None, max_age_days: int = 30, report_kind: str = 'scan', limit: int = 5) -> list[dict]

Parameter Type Default Description
scanner str | None None Filter by scanner name (e.g., "cloudsploit", "trivy", "prowler"). None matches all.
framework str | None None Compliance framework filter (e.g., "HIPAA"). None matches all.
provider str | None None Cloud provider filter (e.g., "aws"). None matches all.
scope_match dict | None None JSONB containment filter for the scope dict (e.g., {"account_id": "123"} matches any report whose scope contains that key-value pair).
max_age_days int 30 Only return reports produced within the last max_age_days days (default 30). Set higher to look further back.
report_kind str 'scan' Report kind to filter on. One of "scan", "weekly_summary", "monthly_summary", "drift_comparison" (default "scan").
limit int 5 Maximum number of reports to return (default 5).

Returns: list[dict] — List of report metadata dicts (JSON-serializable), sorted by produced_at descending. Empty list if no match found.

Method SecurityReportToolkit.read_security_report

Read a specific section of a security report.

Section semantics:

  • "summary" — Returns metadata (severity counts, scanner, scope) WITHOUT downloading full content. Start here.
  • "critical" — Returns only CRITICAL findings (fetches content).
  • "high" — Returns only HIGH findings (fetches content).
  • "medium" — Returns only MEDIUM findings (fetches content).
  • "low" — Returns only LOW findings (fetches content).
  • "executive" — Returns narrative paragraph (only meaningful for WEEKLY_SUMMARY / MONTHLY_SUMMARY report kinds; other parsers return an empty paragraph string).
  • "full" — Returns the entire parsed structure (fetches content). Use sparingly; full reports can be large.

read_security_report(report_id: str, section: Literal['summary', 'critical', 'high', 'medium', 'low', 'executive', 'full'] = 'summary') -> dict

Parameter Type Default Description
report_id str UUID of the report to read.
section Literal['summary', 'critical', 'high', 'medium', 'low', 'executive', 'full'] 'summary' Named section to extract. Defaults to "summary".

Returns: dict — Section-specific dict. Returns {"error": "..."} if the report is not found. Raises ValueError if section is not one of the supported values.

Method SecurityReportToolkit.search_findings

Search security findings across catalog reports.

v1 LIMITATION: This method only matches against the embedded top_findings JSONB column (the top-10 findings stored at write time per report). Findings ranked 11th or lower within a report are NOT included in search results. Communicate this limitation to users when they ask broad questions — a finding may exist in the catalog without appearing here.

search_findings(query: str, scanner: str | None = None, severity: Literal['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'] | None = None, since_days: int = 30, limit: int = 20) -> list[dict]

Parameter Type Default Description
query str Free-text search string matched against finding titles and descriptions (case-insensitive substring match on top_findings::text).
scanner str | None None Narrow to a specific scanner. None searches all.
severity Literal['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'] | None None Filter by severity level. None searches all severity levels.
since_days int 30 Look back at most since_days days (default 30).
limit int 20 Maximum number of reports to search (default 20).

Returns: list[dict] — List of finding dicts {report_id, scanner, framework, severity, title, resource, description} that match the query.

Method SecurityReportToolkit.list_available_frameworks

List compliance frameworks for which reports exist in the catalog.

Useful for diagnosing what data is available before calling find_security_report.

list_available_frameworks() -> list[str]

Returns: list[str] — Sorted, deduplicated list of framework strings (e.g., ["HIPAA", "PCI", "SOC2"]). Empty list if no reports exist.

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