Skip to content

Instantly share code, notes, and snippets.

@AnowarCST
Created October 24, 2025 20:17
Show Gist options
  • Select an option

  • Save AnowarCST/9b9fbb2867e066cd01509da9481f74bb to your computer and use it in GitHub Desktop.

Select an option

Save AnowarCST/9b9fbb2867e066cd01509da9481f74bb to your computer and use it in GitHub Desktop.
DevSecOps in the AI Era — Security Gates that Scale (Quickstart)

DevSecOps in the AI Era — Security Gates that Scale (Quickstart)

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.


TL;DR

  • 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.

Pipeline (at a glance)

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+]
Loading

Start Monday — Checklist (5 steps)

  1. Enforce SonarCloud Quality Gate on PRs (High/Critical fail).
  2. Enable AI review assistants (as reviewers, not approvers).
  3. Add ZAP Baseline in CI; fail PR on Medium+.
  4. Nightly Full ZAP (active) on staging; triage noise, tune rules.
  5. Metrics tiles on team dashboard (block-rate, MTTR, flow-coverage).

GitHub Actions — examples

1) SonarCloud (SAST/SCA)

# .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.

2) Playwright → ZAP (Baseline on PR)

# .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.out

Playwright 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
});

ZAP tuning (quick hits)

  • 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.

Human × AI Review (policy)

  • 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.

Metrics (track weekly)

  • Block-rate of Medium+ on PRs.
  • MTTR to remediate.
  • DAST flow-coverage (% critical user journeys).
  • False-positive rate (keep <10%).
  • SBOM coverage (present & signed).

External awareness (optional)

  • OSS: OWASP Amass (asset discovery), Nuclei (templated checks).
  • SaaS (examples): StackHawk, Invicti, Burp Suite Enterprise, Intruder, Defender EASM.
  • Run weekly; file tickets to SecOps.

Redaction checklist (for screenshots)

Blur: hostnames, repo names, env IDs, emails, tokens, ticket refs.
Keep: vuln type, evidence snippet, affected path, recommended fix.


Credits & useful links


License: MIT • Author: Anowar (Solution Architect)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment