<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
# Compliance Reporting — API Reference

## AWS Config Compliance

```python
import boto3

config = boto3.client("config")

# Get compliance summary
resp = config.get_compliance_summary_by_config_rule()

# Get non-compliant resources
resp = config.get_compliance_details_by_config_rule(
    ConfigRuleName="encrypted-volumes",
    ComplianceTypes=["NON_COMPLIANT"],
)
```

## AWS Security Hub Findings

```python
securityhub = boto3.client("securityhub")

resp = securityhub.get_findings(Filters={
    "ComplianceStatus": [{"Value": "FAILED", "Comparison": "EQUALS"}],
    "GeneratorId": [{"Value": "pci-dss", "Comparison": "PREFIX"}],
})
```

## Azure Policy Compliance

```python
from azure.mgmt.policyinsights import PolicyInsightsClient

client = PolicyInsightsClient(credential, subscription_id)
results = client.policy_states.list_query_results_for_subscription(
    policy_states_resource="latest",
    query_options={"filter": "complianceState eq 'NonCompliant'"},
)
```

## Report Generation (Jinja2)

```python
from jinja2 import Template

template = Template("""
# {{ framework }} Compliance Report
Generated: {{ report_date }}

## Summary
- Total Controls: {{ summary.total_controls }}
- Compliant: {{ summary.compliant }}
- Non-Compliant: {{ summary.non_compliant }}
- Compliance: {{ summary.compliance_percentage }}%

## Findings
{% for gap in gaps %}
### {{ gap.control_id }}: {{ gap.title }}
Status: {{ gap.status }} | Priority: {{ gap.remediation_priority }}
{% endfor %}
""")
```

## Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Report generated — fully compliant |
| 1 | Report generated — gaps found |
| 2 | Report generation failed |
