Skip to content

API Reference parrot.storage.security_reports.store

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

parrot.storage.security_reports.store

View source

SecurityReportStore Protocol + PostgresS3SecurityReportStore implementation.

The store is the catalog's persistence core:

  • Postgres holds metadata (queryable, indexed) via asyncdb.AsyncDB.
  • S3 holds content (cheap, large blobs) via FileManagerInterface.

Key design invariants:

  1. S3 upload FIRST, Postgres INSERT second (S3-wins, Postgres-reconciled).
  2. query() NEVER applies an implicit since filter — visibility window is the caller's responsibility (spec §5 hard requirement).
  3. delete() is reserved for explicit GDPR requests; never called by automatic retention paths (spec §1 Goals: compliance retention).
  4. bootstrap_schema() is idempotent (all DDL uses IF NOT EXISTS).

Alias EmbeddedFinding

Re-exported from parrot.storage.security_reports.models.EmbeddedFinding.

Alias FileManagerInterface

Re-exported from parrot.interfaces.file.FileManagerInterface.

Class PostgresS3SecurityReportStore

Postgres (metadata) + S3/FileManager (content) catalog implementation.

Parameter Type Default Description
dsn str
file_manager FileManagerInterface
s3_prefix str 'security-reports/'

Method PostgresS3SecurityReportStore.save_report

Upload content to S3 first, then insert metadata into Postgres.

S3 upload runs first (orphan-tolerant per spec §7 R8). If metadata insert fails, the S3 object is orphaned — acceptable for v1. Returns the ref with uri populated.

save_report(ref: ReportRef, content: bytes | Path) -> ReportRef

Parameter Type Default Description
ref ReportRef
content bytes | Path

Returns: ReportRef

Method PostgresS3SecurityReportStore.index

Insert metadata only (content was already uploaded externally).

index(ref: ReportRef) -> None

Parameter Type Default Description
ref ReportRef

Method PostgresS3SecurityReportStore.query

Query the catalog.

CRITICAL: No implicit since filter is applied — ALL matching reports are returned regardless of age. Set filter.since when you need a time window (spec §5 hard requirement).

query(filter: ReportFilter) -> list[ReportRef]

Parameter Type Default Description
filter ReportFilter

Returns: list[ReportRef]

Method PostgresS3SecurityReportStore.get

Fetch a single ReportRef by primary key.

get(report_id: UUID) -> ReportRef | None

Parameter Type Default Description
report_id UUID

Returns: ReportRef | None

Method PostgresS3SecurityReportStore.fetch_content

Download and return the content bytes for a report.

fetch_content(report_id: UUID) -> bytes

Parameter Type Default Description
report_id UUID

Returns: bytes

Method PostgresS3SecurityReportStore.delete

Hard-delete a report (GDPR-only). Removes both Postgres row and S3 content.

delete(report_id: UUID) -> None

Parameter Type Default Description
report_id UUID

Method PostgresS3SecurityReportStore.query_distinct_frameworks

Return distinct non-null framework values via SQL DISTINCT query.

query_distinct_frameworks() -> list[str]

Returns: list[str]

Method PostgresS3SecurityReportStore.bootstrap_schema

Idempotently apply schema.sql to the connected database.

Uses importlib.resources so the .sql file is always located relative to this package regardless of CWD.

bootstrap_schema() -> None

Alias ReportFilter

Re-exported from parrot.storage.security_reports.models.ReportFilter.

Alias ReportKind

Re-exported from parrot.storage.security_reports.models.ReportKind.

Alias ReportRef

Re-exported from parrot.storage.security_reports.models.ReportRef.

Class SecurityReportStore

Protocol for the security report catalog persistence layer.

Implementations back this with any combination of metadata store and content store. The reference implementation uses Postgres + S3.

Method SecurityReportStore.save_report

Upload content and persist metadata. Returns the ref with uri set.

save_report(ref: ReportRef, content: bytes | Path) -> ReportRef

Parameter Type Default Description
ref ReportRef
content bytes | Path

Returns: ReportRef

Method SecurityReportStore.index

Index-only path: insert metadata for a ref whose content was already uploaded separately. No S3 upload performed.

index(ref: ReportRef) -> None

Parameter Type Default Description
ref ReportRef

Method SecurityReportStore.query

Query the catalog by filter. Never applies an implicit age filter.

query(filter: ReportFilter) -> list[ReportRef]

Parameter Type Default Description
filter ReportFilter

Returns: list[ReportRef]

Method SecurityReportStore.get

Fetch a single ReportRef by primary key. None if not found.

get(report_id: UUID) -> ReportRef | None

Parameter Type Default Description
report_id UUID

Returns: ReportRef | None

Method SecurityReportStore.fetch_content

Download and return the content bytes for a report.

fetch_content(report_id: UUID) -> bytes

Parameter Type Default Description
report_id UUID

Returns: bytes

Method SecurityReportStore.delete

Hard-delete a report (GDPR-only). Not used by retention logic.

delete(report_id: UUID) -> None

Parameter Type Default Description
report_id UUID

Method SecurityReportStore.query_distinct_frameworks

Return distinct non-null framework values from the catalog.

query_distinct_frameworks() -> list[str]

Returns: list[str]

Method SecurityReportStore.bootstrap_schema

Idempotently apply schema.sql to the Postgres database.

bootstrap_schema() -> None

Alias SeverityBreakdown

Re-exported from parrot.storage.security_reports.models.SeverityBreakdown.

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