Skip to content

API Reference parrot_tools.security.reports.compliance_mapper

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

parrot_tools.security.reports.compliance_mapper

View source

Compliance Mapper for security findings.

Maps normalized SecurityFinding objects to compliance framework controls (SOC2, HIPAA, PCI-DSS, etc.), enabling cross-tool compliance reporting.

Alias ComplianceFramework

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

Class ComplianceMapper

Maps security findings to compliance framework controls.

Maintains a mapping database from:

  • Prowler check IDs → compliance controls
  • Trivy vulnerability types → compliance controls
  • Checkov policy IDs → compliance controls

The mapper loads YAML mapping files that define the relationship between scanner-specific check IDs and framework controls.

Parameter Type Default Description
mappings_dir Optional[str] None Path to directory containing YAML mapping files. Defaults to the 'mappings' subdirectory next to this module.

Method ComplianceMapper.map_finding_to_controls

Map a security finding to relevant compliance controls.

map_finding_to_controls(finding: SecurityFinding, framework: ComplianceFramework) -> list[str]

Parameter Type Default Description
finding SecurityFinding The security finding to map.
framework ComplianceFramework The compliance framework to map to.

Returns: list[str] — List of control IDs that the finding maps to. Returns empty list if no mapping exists.

Method ComplianceMapper.get_framework_coverage

Calculate compliance coverage for a framework based on findings.

Analyzes the findings to determine:

  • Which controls have been checked (have associated findings)
  • Which controls passed vs failed
  • Overall coverage percentage

get_framework_coverage(findings: list[SecurityFinding], framework: ComplianceFramework) -> dict

Parameter Type Default Description
findings list[SecurityFinding] List of security findings to analyze.
framework ComplianceFramework The compliance framework to calculate coverage for.

Returns: dict — Dictionary with coverage metrics:

  • total_controls: Total number of controls in the framework
  • checked_controls: Number of controls with associated findings
  • passed_controls: Number of controls where all findings passed
  • failed_controls: Number of controls with at least one failed finding
  • unchecked_controls: Number of controls with no associated findings
  • coverage_pct: Percentage of controls that were checked
  • pass_pct: Percentage of checked controls that passed

Method ComplianceMapper.get_control_details

Get details for a specific compliance control.

get_control_details(control_id: str, framework: ComplianceFramework) -> Optional[dict]

Parameter Type Default Description
control_id str The ID of the control (e.g., "CC6.1" for SOC2).
framework ComplianceFramework The compliance framework the control belongs to.

Returns: Optional[dict] — Dictionary with control details including name, description, and category. Returns None if the control is not found.

Method ComplianceMapper.get_all_controls

Get all controls for a compliance framework.

get_all_controls(framework: ComplianceFramework) -> dict[str, dict]

Parameter Type Default Description
framework ComplianceFramework The compliance framework.

Returns: dict[str, dict] — Dictionary of control_id -> control details.

Method ComplianceMapper.get_findings_by_control

Group findings by the controls they map to.

get_findings_by_control(findings: list[SecurityFinding], framework: ComplianceFramework) -> dict[str, list[SecurityFinding]]

Parameter Type Default Description
findings list[SecurityFinding] List of security findings.
framework ComplianceFramework The compliance framework to use for mapping.

Returns: dict[str, list[SecurityFinding]] — Dictionary mapping control IDs to lists of findings.

Method ComplianceMapper.get_unmapped_findings

Get findings that don't map to any control in the framework.

get_unmapped_findings(findings: list[SecurityFinding], framework: ComplianceFramework) -> list[SecurityFinding]

Parameter Type Default Description
findings list[SecurityFinding] List of security findings.
framework ComplianceFramework The compliance framework to check against.

Returns: list[SecurityFinding] — List of findings that have no control mappings.

Alias FindingSource

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

Alias SecurityFinding

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

Alias SeverityLevel

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

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