The author has deployed nested pipelines with 6 security scanners, AI triage of severity, and a mandatory human gate for critical vulnerabilities. CI/CD now classifies findings on its own, prioritizes fixes, and requires human approval only for critical cases.
The Security Pipeline Architecture in Detail
Nested pipelines make it possible to split the process into independent stages: scan, triage, gate, remediation, verification. Each stage runs in an isolated environment with its own timeouts and retry policies. The parent pipeline receives only artifacts and verdicts from the child pipelines, so a single scanner failing does not bring down the whole build — it is restarted point-by-point. Timeouts: scan — 15 minutes per scanner, triage — 5 minutes, remediate — 40 minutes; on failure, up to two retries with exponential backoff.
A Nested Pipeline in GitLab CI: scan → triage → gate → remediate
stages: [scan, triage, gate, remediate]
scan:sast:
stage: scan
script: semgrep ci --config p/owasp-top-ten --json -o reports/sast.json
scan:sca:
stage: scan
script: trivy fs --format sarif -o reports/sca.sarif .
scan:secrets:
stage: scan
script: gitleaks detect --report-path reports/secrets.json
scan:container:
stage: scan
script: trivy image $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA -o reports/image.json
allow_failure: true
triage:ai:
stage: triage
needs: [scan:sast, scan:sca, scan:secrets, scan:container]
script: python triage_agent.py --in reports/ --out verdicts.json
artifacts: {paths: [verdicts.json]}
gate:human:
stage: gate
script: python open_jira_gate.py --verdicts verdicts.json --threshold 0.85
when: manual
remediate:auto:
stage: remediate
needs: [triage:ai]
script: python auto_patch.py --verdicts verdicts.json --max-cvss 7.0
only: {changes: ["**/*.lock", "Dockerfile"]}
Configuring the 6 Security Scanners
- SAST — static code analysis: SonarQube, Semgrep, CodeQL; run on every merge request.
- DAST — dynamic analysis of the running application: OWASP ZAP against the staging environment, a nightly run.
- SCA — dependency analysis: OWASP Dependency-Check, Snyk; weekly and on every PR.
- Container — container image scanning: Trivy, Grype; on every built image.
- Secrets — secret detection in code: TruffleHog, GitLeaks; pre-commit plus CI.
- IaC — infrastructure-as-code checks: Checkov, tfsec; on terraform and helm changes.
AI Triage: The Threat Prioritization Algorithm
The model is trained on the company’s historical security incident data. Features: CVSS score, exploitability, asset criticality, the existence of a public exploit. The escalation threshold to the human gate is 0.85 probability of a critical vulnerability. On a held-out sample the model reaches a precision of 0.93 with a recall of 0.89 on the class of critical findings; the threshold calibration is revisited every quarter.
Triage Model Features
| Feature | Type | Contribution to the decision |
|---|---|---|
| CVSS base score | number 0-10 | high |
| Exploitability (reachability from the external perimeter) | binary | high |
| Asset criticality (prod, payment service, internal tool) | category | high |
| Public exploit in Exploit-DB / CISA KEV | binary | critical |
| Official vendor patch available | binary | medium |
| Package version lagging behind the fix | number | medium |
The SLA Matrix by Severity
| Severity | Model verdict | Action | SLA |
|---|---|---|---|
| Critical | p >= 0.85 | human-gate, a Jira Critical ticket | 30 minutes by day, 2 hours at night |
| High | p 0.60-0.85 | auto-ticket + auto-patch into a feature branch | 24 hours |
| Medium | p 0.30-0.60 | a task in the security backlog | 7 days |
| Low | p < 0.30 | a note in the report, no ticket | 30 days |
Human Gate: The Human Approval Process
When the 0.85 threshold fires, a Jira ticket is created with Critical priority. The responsible DevSecOps engineer gets a Slack notification with context: the CVE, affected services, the recommended action (patch, mitigation, or risk acceptance). The response SLA is 30 minutes during business hours, 2 hours at night. If the engineer does not respond within the SLA, the ticket escalates to their manager, and the pipeline blocks merges into protected branches. The engineer’s decision (confirm, downgrade, reject) is written back into the dataset as a label for further training.
Remediation: What the Auto-Patch Does
The remediate stage is confined to a safe corridor: version bumps in lock files, moving the base image to the same tag with a patch, replacing a vulnerable dependency with a compatible one from an allowlist. The auto-patch is forbidden from touching application sources and configuration. The result is a remediate branch with a green run of all tests; without a green run, no MR is created, and the finding returns to the triage queue. From the author’s experience, automation closes 60-70% of SCA-class findings. Verification: a child pipeline rebuilds the image and re-runs the container scanner; if the finding remains, the discrepancy is automatically escalated to the human gate with a triage-miss label.
Handling False Positives: The Feedback Loop
False positives are the main reason teams switch scanners off. The feedback scheme: every finding dismissed by an engineer is labeled with a reason (not reachable, test code, a scanner’s false pattern, fixed earlier) and goes into the training dataset. Every two weeks the model is retrained, and for recurring false patterns, suppression rules are created in Semgrep and Trivy ignore files with a mandatory lifetime and an owner — suppression without an expiration date is forbidden by policy. The target metric is the share of false positives among escalated findings below 10%.
Pipeline Metrics and Monitoring
Prometheus metrics: cicd_scan_duration_seconds, cicd_vulnerabilities_total, cicd_triage_accuracy, cicd_human_gate_response_seconds. A Grafana dashboard with alerts on anomalies: a sudden spike in critical findings, triage accuracy dropping below 0.9, human-gate response time exceeding the SLA. Scanner reports are stored in S3-compatible storage with a 90-day retention and the commit hash in the key.
Environment Requirements
A runner with Docker and access to the internal image registry, a Jira service token, a subscription to the CISA KEV feed (updated hourly), and a dedicated vLLM or API backend for the triage model with a limit of 30 requests per minute — so that triage does not become the pipeline’s new bottleneck.
Phased Rollout Plan
- Phase 1 (2 weeks): 6 scanners in shadow mode, findings go only into reports, no merge blocking.
- Phase 2 (4 weeks): AI triage on historical data, comparing verdicts with real incidents, threshold calibration.
- Phase 3 (4 weeks): human gate for Critical with an SLA, auto-patches for High into feature branches, feedback loop.
- Phase 4 (ongoing): expanding suppression rules, retraining every two weeks, precision/recall audits.
More on the foundational practices: CI/CD security, AI in DevOps, and an overview of security scanners.
Useful resources: Semgrep documentation, Trivy documentation.
Checklist for deploying a self-healing CI/CD:
1) SAST (SonarQube, Semgrep, CodeQL) — on every merge request.
2) DAST (OWASP ZAP) — a nightly run against staging.
3) SCA (Dependency-Check, Snyk) — weekly plus on every PR.
4) Container (Trivy, Grype) — on every built image.
5) Secrets (TruffleHog, GitLeaks) — pre-commit and in CI.
6) IaC (Checkov, tfsec) — on terraform and helm changes.
7) AI triage: a model trained on historical incidents, features CVSS, exploitability, asset criticality, public exploit; the human-gate threshold 0.85.
9) Metrics: scan_duration, vulnerabilities_total, triage_accuracy, human_gate_response.
10) Feedback loop: dismissals are labeled with a reason, retraining every two weeks, suppressions only with an expiration date.

