Skip to content

API Reference parrot_tools.security.persistence

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

parrot_tools.security.persistence

View source

ReportPersistenceMixin — catalog write-side mixin for producer toolkits.

Scanner toolkits (CloudSploit, ComplianceReport, ContainerSecurity) compose this mixin to gain automatic report cataloging without coupling to the store internals.

Construction protocol

Producer toolkits that inherit from both this mixin and AbstractToolkit MUST pop file_manager and report_store from **kwargs before calling super().__init__(**kwargs), otherwise AbstractToolkit receives unknown keyword arguments.

Example::

class MyToolkit(ReportPersistenceMixin, AbstractToolkit):
    def __init__(self, *, config, **kwargs):
        self.file_manager, self.report_store = pop_persistence_kwargs(kwargs)
        super().__init__(**kwargs)
        self.config = config

Class ReportPersistenceMixin

Mixin that gives producer toolkits catalog write capability.

When file_manager AND report_store are both non-None, _persist_report uploads content to S3 and indexes metadata in Postgres via the store. When either dependency is None, the method is a no-op (returns None silently) — existing callers that do not inject persistence deps continue working unchanged.

Class attributes (set per-instance in the constructor): file_manager: Active FileManagerInterface or None. report_store: Active SecurityReportStore or None. parser_version: Version string forwarded to ReportRef.parser_version.

Attributes:

Attribute Type Description
file_manager FileManagerInterface | None
report_store SecurityReportStore | None
parser_version str

Alias get_report_parser

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

Function pop_persistence_kwargs

Pop file_manager and report_store from a toolkit's **kwargs.

Call this BEFORE super().__init__(**kwargs) in producer toolkit constructors to prevent unknown-kwarg errors in AbstractToolkit.

pop_persistence_kwargs(kwargs: dict[str, Any]) -> tuple[FileManagerInterface | None, SecurityReportStore | None]

Parameter Type Default Description
kwargs dict[str, Any] The **kwargs dict from the toolkit constructor. Modified in place — both keys are removed if present.

Returns: tuple[FileManagerInterface | None, SecurityReportStore | None] — A (file_manager, report_store) tuple; either may be None if not present in kwargs.

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