Skip to content

API Reference parrot_tools.security.base_parser

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

parrot_tools.security.base_parser

View source

Base parser for normalizing security scanner output.

Provides an abstract interface for parsing scanner-specific output into the unified SecurityFinding and ScanResult models.

Class BaseParser

Abstract parser for security scanner output.

Each scanner (Prowler, Trivy, Checkov) implements its own parser that normalizes raw output into the unified ScanResult format.

Subclasses must implement:

  • parse(): Parse raw scanner stdout into a normalized ScanResult
  • normalize_finding(): Convert a single raw finding into SecurityFinding

Method BaseParser.parse

Parse raw scanner stdout into a normalized ScanResult.

Implementations should:

  • Handle empty or malformed input gracefully
  • Extract findings and build a ScanSummary
  • Return an empty ScanResult on parse errors, not raise exceptions

parse(raw_output: str) -> ScanResult

Parameter Type Default Description
raw_output str Raw string output from the scanner (usually JSON).

Returns: ScanResult — Normalized ScanResult with findings and summary.

Method BaseParser.normalize_finding

Convert a single raw finding into a unified SecurityFinding.

Implementations should:

  • Map scanner-specific severity levels to SeverityLevel enum
  • Extract resource, region, and other metadata
  • Preserve original data in the 'raw' field

normalize_finding(raw_finding: dict) -> SecurityFinding

Parameter Type Default Description
raw_finding dict Dictionary from scanner output representing one finding.

Returns: SecurityFinding — Normalized SecurityFinding instance.

Method BaseParser.save_result

Persist scan result to a JSON file.

Creates parent directories if they don't exist.

save_result(result: ScanResult, path: str) -> str

Parameter Type Default Description
result ScanResult The ScanResult to save.
path str Destination file path.

Returns: str — Absolute path of the saved file.

Method BaseParser.load_result

Load a previously saved scan result from JSON file.

load_result(path: str) -> ScanResult

Parameter Type Default Description
path str Path to the JSON file.

Returns: ScanResult — Deserialized ScanResult.

Raises:

  • FileNotFoundError — If the file doesn't exist.

Alias ScanResult

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

Alias SecurityFinding

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

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