Implementation:0xSteph Pentest ai Compliance Mapping
| Knowledge Sources | |
|---|---|
| Domains | Compliance, Mapping, PCI_DSS, HIPAA, SOC2 |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for mapping CWE IDs and finding categories to PCI-DSS, HIPAA, SOC2, and OWASP compliance controls, provided by the pentest-ai engine.
Description
The map_finding_compliance function takes a finding dict with cwe_id and/or category and returns a dict mapping compliance frameworks (pci_dss, hipaa, soc2, owasp) to their relevant control identifiers. It uses three lookup tables: CWE_TO_PCI, CWE_TO_HIPAA, CWE_TO_SOC2, and a CATEGORY_COMPLIANCE dict for category-based mapping. Covers categories including network, web, authentication, injection, xss, ssrf, authorization, secrets, headers, and ssl.
Usage
Import this function when you need to annotate findings with compliance framework mappings. Used by the report generator and SARIF export.
Code Reference
Source Location
- Repository: 0xSteph_Pentest_ai
- File: engine/compliance.py
- Lines: 1-173
Signature
CWE_TO_PCI: dict[str, list[str]] = ...
CWE_TO_HIPAA: dict[str, list[str]] = ...
CWE_TO_SOC2: dict[str, list[str]] = ...
CATEGORY_COMPLIANCE: dict[str, dict[str, list[str]]] = ...
def map_finding_compliance(finding: dict[str, Any]) -> dict[str, list[str]]: ...
Import
from engine.compliance import map_finding_compliance, CWE_TO_PCI, CWE_TO_HIPAA, CWE_TO_SOC2
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| finding | dict[str, Any] | Yes | Finding dict with cwe_id, owasp_category, and/or category fields |
Outputs
| Name | Type | Description |
|---|---|---|
| compliance mapping | dict[str, list[str]] | Keys: pci_dss, hipaa, soc2, owasp; values: control ID lists |
Usage Examples
Map a Finding
from engine.compliance import map_finding_compliance
finding = {
"title": "SQL injection in search",
"severity": "critical",
"category": "injection",
"cwe_id": "CWE-89",
}
mapping = map_finding_compliance(finding)
print(mapping)
# {
# "pci_dss": ["6.5.1"],
# "hipaa": ["164.312(a)(1)"],
# "soc2": ["CC6.1"],
# "owasp": ["A03:2021"],
# }