Implementation:0xSteph Pentest ai JUnit XML Export
| Knowledge Sources | |
|---|---|
| Domains | Export, JUnit, CI_CD |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for converting pentest findings into JUnit XML format for CI systems to display as test results, provided by the pentest-ai engine.
Description
The findings_to_junit function converts a list of finding dicts into JUnit XML format. Critical and high severity findings become test failures, while medium/low/info become system-out entries. Each finding maps to a testcase with the finding title as name, category as classname, and description/target/CVSS/remediation as failure text.
Usage
Import this function when you need to export findings as JUnit XML for CI integration. Used by the CI gate and report generator.
Code Reference
Source Location
- Repository: 0xSteph_Pentest_ai
- File: engine/junit_xml.py
- Lines: 1-50
Signature
FAILURE_SEVERITIES = frozenset({"critical", "high"})
def findings_to_junit(
findings: list[dict[str, Any]],
engagement: dict[str, Any],
) -> str: ...
Import
from engine.junit_xml import findings_to_junit
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| findings | list[dict] | Yes | Findings with title, severity, category, description, target |
| engagement | dict | Yes | Engagement dict with target |
Outputs
| Name | Type | Description |
|---|---|---|
| xml | str | JUnit XML string with testsuite and testcases |
Usage Examples
Export to JUnit XML
from engine.junit_xml import findings_to_junit
findings = [
{"title": "SQLi in search", "severity": "critical", "category": "injection",
"description": "Boolean-based SQLi", "target": "https://example.com/search",
"cwe_id": "CWE-89", "cvss_score": 9.8, "remediation": "Use parameterized queries"},
{"title": "Missing HSTS", "severity": "info", "category": "misconfiguration",
"description": "HSTS header not set", "target": "https://example.com"},
]
xml = findings_to_junit(findings, {"target": "example.com"})
Path("security-report.xml").write_text(xml)