Promise: Ship fast and safe by embedding three gates in CI/CD: SAST/SCA (SonarCloud), AI-assisted peer review, and DAST (Playwright → OWASP ZAP).
Audience: Security specialists, architects, senior devs.
Outcome: A minimal, repeatable pattern you can enable on Monday.
- Shift-left: SonarCloud Quality Gate on PRs (fail High/Critical).
- Review: Human + AI assistants (Copilot PR / Amazon Q / CodeRabbit).
- Runtime: Route Playwright traffic via ZAP; fail PR on Medium+.
- External (optional): Light EASM/DAST weekly (Amass, Nuclei or SaaS).
- Measure: Block-rate, MTTR, DAST flow-coverage, FP-rate, SBOM coverage.
flowchart LR
A[Commit/PR] --> B[SonarCloud: SAST/SCA]
B --> C[Peer + AI Review\n(Copilot PR / Amazon Q / CodeRabbit)]
C --> D[CI: Playwright E2E]
D --> E[OWASP ZAP Proxy (8090)]
E --> F[Application (8080)]
E --> G[ZAP HTML/XML Report]
G --> H[CI Gate: Fail on Medium+]
- Enforce SonarCloud Quality Gate on PRs (High/Critical fail).
- Enable AI review assistants (as reviewers, not approvers).
- Add ZAP Baseline in CI; fail PR on Medium+.
- Nightly Full ZAP (active) on staging; triage noise, tune rules.
- Metrics tiles on team dashboard (block-rate, MTTR, flow-coverage).
# .github/workflows/sonarcloud.yml
name: sonarcloud
on:
pull_request:
push:
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@v2
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_PROJECT_KEY: your-org_your-project
SONAR_ORGANIZATION: your-org
# Enforce this check as "required" in branch protection.# .github/workflows/dast-baseline.yml
name: dast-baseline
on: [pull_request]
jobs:
zap:
runs-on: ubuntu-latest
services:
app:
image: node:20
ports: [ "8080:8080" ]
options: >-
--health-cmd="curl -f http://localhost:8080/health || exit 1"
--health-interval=5s --health-timeout=2s --health-retries=20
# Replace with your app start command:
command: bash -lc "npm i && npm run start"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci && npx playwright install --with-deps
- name: Start OWASP ZAP (daemon)
run: |
docker run -d --name zap -p 8090:8090 ghcr.io/zaproxy/zaproxy:stable zap.sh -daemon -port 8090 -host 0.0.0.0 -config api.disablekey=true
- name: Run Playwright via proxy
env:
ZAP_PROXY: http://127.0.0.1:8090
run: |
echo "Ensure your Playwright launch picks up ZAP_PROXY"
npm test
- name: ZAP Baseline Scan (fail on Medium+)
uses: zaproxy/action-baseline@v0.11.0
with:
target: "http://localhost:8080"
fail_action: true
cmd_options: "-a -m 1"
- name: Upload ZAP report
uses: actions/upload-artifact@v4
with:
name: zap-report
path: |
report.html
zap.outPlaywright proxy tip (Node):
// tests/setup.ts (example)
import { chromium } from 'playwright';
const browser = await chromium.launch({
proxy: process.env.ZAP_PROXY ? { server: process.env.ZAP_PROXY } : undefined
});- PR = Baseline (passive); Nightly = Full (active).
- Add auth contexts/scripts; enable AJAX spider for SPAs.
- Exclude noise:
/health,/metrics,/static/*. - Gate: Medium+ for PR; tune per repo.
- AI assistants suggest; humans decide.
- Require design intent in PR description.
- Store AI prompt/context in PR comments or artefacts.
- Block merge if required human reviewer not satisfied.
- Block-rate of Medium+ on PRs.
- MTTR to remediate.
- DAST flow-coverage (% critical user journeys).
- False-positive rate (keep <10%).
- SBOM coverage (present & signed).
- OSS: OWASP Amass (asset discovery), Nuclei (templated checks).
- SaaS (examples): StackHawk, Invicti, Burp Suite Enterprise, Intruder, Defender EASM.
- Run weekly; file tickets to SecOps.
Blur: hostnames, repo names, env IDs, emails, tokens, ticket refs.
Keep: vuln type, evidence snippet, affected path, recommended fix.
- DevSecOps Pipeline Checklist by @oazabir → https://gist.github.com/oazabir/299153909cf26b3b503cccfd1068c102
- OWASP ZAP → https://www.zaproxy.org/
- Playwright → https://playwright.dev/
- SonarCloud → https://sonarcloud.io/
- Slide → Gamma
License: MIT • Author: Anowar (Solution Architect)