Principle:0xSteph Pentest ai CI CD Security Gate Principle
| Knowledge Sources | |
|---|---|
| Domains | Security_Testing, CI_CD, DevSecOps |
| Last Updated | 2026-10-23 12:00 GMT |
Overview
A security-gate pattern that runs a penetration test as a CI/CD step, gates builds on verified findings using severity thresholds, and exports results as SARIF for code-scanning integration.
Description
CI/CD Security Gate is the principle that dynamic security testing can gate software builds the same way unit tests do: run the test, count findings at or above a severity threshold, and fail the build if any meet the gate. It solves the problem that security testing is often a manual, after-the-fact activity rather than a continuous integration step.
The gate operates on verified findings only (when using `--fail-on verified`) so that false positives from scanners cannot block a build. The CI mode outputs JSON to stdout for machine consumption and uses exit codes (0 = clean, 1 = gated).
The gate integrates with CI platforms:
- SARIF export: Verified findings → SARIF v2.1.0 JSON with webRequest/webResponse for DAST, consumed by GitHub Code Scanning
- GitHub Actions: Step outputs written to GITHUB_OUTPUT, PR comment posted via GitHub API
- AUP gate: `PENTEST_AI_AUP_ACCEPTED=1` enables non-interactive consent for CI
Usage
Use this principle when:
- Security testing should be a CI step, not a manual activity
- Builds should fail on verified high-severity findings but not on scanner false positives
- You need SARIF output for GitHub Code Scanning or Azure DevOps integration
- You want to post security results as PR comments
Theoretical Basis
The gate is a threshold function on verified findings:
SARIF is a standardized results interchange format:
# Abstract SARIF structure (NOT real implementation)
sarif = {
"$schema": "https://...sarif-schema-2.1.0.json",
"version": "2.1.0",
"runs": [{
"tool": {"driver": {"name": "pentest-ai", ...}},
"results": [...], # one per finding
"invocations": [{...}],
}]
}