Skip to content

API Reference parrot_tools.security.advisory_engine

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

parrot_tools.security.advisory_engine

View source

SecurityAdvisoryEngine — day-over-day diff and SOC2 control mapping.

Pure-logic module: no LLM, no agent, no I/O beyond the injected store and mapper. The agent narrates the structured AdvisoryReport via its LLM.

Implements FEAT-226 spec §3 Module 1.

Class AdvisoryRecommendation

One actionable recommendation tied to SOC2 controls.

Fields:

Field Type Default Description
title str Short recommendation title.
severity str Severity level driving this recommendation.
soc2_control_ids list[str] SOC2 control IDs from ComplianceMapper.
affected_resources list[str] Resource identifiers affected.
recommended_action str Concrete remediation step.
is_material bool True for new/severity-increased CRITICAL or HIGH findings; gates Jira ticket creation.

Class AdvisoryReport

Structured day-over-day SOC2 advisory for one framework.

No narrative: the agent's LLM writes prose from this model.

Fields:

Field Type Default Description
framework str Compliance framework identifier (e.g. 'soc2').
baseline_report_id str | None Prior-day report ID (None on first run).
current_report_id Optional[str] None ID of the most-recent report analysed.
severity_delta SeverityBreakdown Signed severity counts (current − baseline).
deltas list[FindingDelta] Per-finding delta records, sorted by severity desc then id.
soc2_coverage dict Output of ComplianceMapper.get_framework_coverage.
control_findings dict[str, int] Mapping of control_id → number of failing findings.
recommendations list[AdvisoryRecommendation] Actionable recommendations, material items first.
provider str 'aws' Cloud provider (recorded for the persisted ReportRef).

Alias ComplianceFramework

Re-exported from parrot_tools.security.models.ComplianceFramework.

Alias ComplianceMapper

Re-exported from parrot_tools.security.reports.ComplianceMapper.

Class FindingDelta

Day-over-day change for a single finding (aligned to SecurityFinding).

Fields:

Field Type Default Description
finding_id str Unique finding identifier (SecurityFinding.id).
status Literal['new', 'resolved', 'persisting', 'severity_changed'] Change classification — new, resolved, persisting, or severity_changed.
severity str Current severity level (SeverityLevel value).
previous_severity str | None None Prior severity when status == 'severity_changed'.
title str Short finding title.
resource str | None None Affected resource identifier (SecurityFinding.resource).
check_id str | None None Scanner-specific check ID (SecurityFinding.check_id).
soc2_control_ids list[str] SOC2 control IDs from ComplianceMapper.

Alias FindingSource

Re-exported from parrot_tools.security.models.FindingSource.

Class SecurityAdvisoryEngine

Deterministic day-over-day security advisory engine.

Given a SecurityReportStore and an optional ComplianceMapper, fetches the two most-recent reports for a framework, diffs their findings, maps the delta to SOC2 controls via the existing ComplianceMapper, and returns a structured AdvisoryReport Pydantic model.

No narrative is written here — the caller's LLM generates prose.

Parameter Type Default Description
report_store SecurityReportStore Catalog backend (query + fetch_content only).
mapper ComplianceMapper | None None Optional pre-constructed ComplianceMapper; a fresh instance with default mappings_dir is created when None.

Method SecurityAdvisoryEngine.build_daily_advisory

Build a day-over-day SOC2 advisory for one framework.

Queries the two most-recent SCAN-kind reports for framework, diffs their findings, maps to SOC2 controls, and returns a fully structured AdvisoryReport.

First run (only one report exists): baseline_report_id is None and every finding is classified as "new".

build_daily_advisory(*, framework: str, provider: str = 'aws') -> AdvisoryReport

Parameter Type Default Description
framework str Compliance framework identifier (e.g. 'soc2').
provider str 'aws' Cloud provider (e.g. 'aws'). Recorded on the returned AdvisoryReport for the caller's ReportRef.

Returns: AdvisoryReport — An AdvisoryReport with signed severity delta, per-finding deltas classified by status, SOC2 coverage, and recommendations.

Alias SecurityFinding

Re-exported from parrot_tools.security.models.SecurityFinding.

Alias SeverityLevel

Re-exported from parrot_tools.security.models.SeverityLevel.

Alias get_report_parser

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

Function parse_findings

Try to parse content into a list of SecurityFinding objects.

The catalog-level parsers return ParsedReport with EmbeddedFinding objects, not the richer SecurityFinding shape required by ComplianceMapper. We therefore call extract_section("full") (returning raw scanner JSON) and reconstruct SecurityFinding objects.

Degrades gracefully: if parsing fails or the scanner is unrecognised, returns an empty list so the caller falls back to severity-summary deltas.

parse_findings(ref: ReportRef, content: bytes) -> list[SecurityFinding]

Parameter Type Default Description
ref ReportRef Report metadata (provides scanner name and framework).
content bytes Raw scanner output bytes.

Returns: list[SecurityFinding] — Possibly-empty list of SecurityFinding objects.

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