HomeRoadmapsSecurity Day 7
Security Track Β· Day 7 Capstone Β· 20 min

Zero-Trust CI/CD Security Verification Gates
Pipeline Automation & SOC 2 Capstone β€” Day 7

Construct an enterprise GitHub Actions pipeline orchestrating SCA, SAST, Secret audits, and Compliance checks with SARIF uploads and SOC 2 audit ledgers.

✨ Agent: Claude 3.7 Sonnet / Gemini 3.5 Β· 200K contextπŸ›‘οΈ AI SecOps & Red-Teaming Architect
Zero-TrustCI/CD GatesGitHub ActionsSARIF UploadSOC2 LedgerCapstone
Capstone Lab Objective

Congratulations on reaching the final day! In this capstone lab, you will tie together everything learned over the past 6 days (SCA, SAST, Secrets detection, DAST, PII compliance, and Auto-Remediation) into a production-grade Zero-Trust CI/CD Security Pipeline. You will configure automated blocking quality gates and emit a cryptographically hashed SOC 2 audit ledger.

πŸ“¦Sample Codebase & Working Solution (Day 7)Available Now
View on GitHub

The official reference codebase for Day 7 is hosted in the repository. Clone the repository and navigate to day-7-zero-trust-pipeline to run the working solution.

Git Clone β€” Working Solution
git clone https://github.com/letstrnsfrm-ai/security-compliance-roadmap.git
cd security-compliance-roadmap/day-7-zero-trust-pipeline
🏭Production Context & Enterprise Implementation
πŸ’‘ Why We Are Doing This: Security tools produce zero value if findings can be silently ignored by developers. A Zero-Trust CI/CD pipeline enforces programmatic blocking gates that guarantee no code with Critical CVEs or hardcoded secrets can ever reach production branches.
🏒 Real-World Production Usecase: Establishing mandatory GitHub branch protection rules where the 'security-verification-gate' status check must be green before PR merge is permitted.
βš™οΈ How Implemented in Production: Unified GitHub Actions YAML executing parallel scan matrices, uploading SARIF to GitHub Security, and appending immutable cryptographic hashes to a SOC2 compliance audit log.
Phase 1

Define Multi-Layered Threat Matrix & SLA Thresholds

Establish the enterprise security SLA rules enforced by the CI/CD pipeline:

Enterprise Security Gating Rules:
  • CRITICAL (CVSS 9.0–10.0): Zero allowed. Pipeline blocks merge immediately. Remediation SLA < 24h.
  • HIGH (CVSS 7.0–8.9): Zero allowed. Pipeline blocks merge immediately. Remediation SLA < 7 days.
  • SECRETS / API KEYS: Zero allowed. Pre-commit & CI hard failure.
  • PII LEAKS: Zero unmasked card numbers or raw credentials allowed in logs or response payloads.
Phase 2

Assemble .github/workflows/security-pipeline.yml

Write the enterprise GitHub Actions workflow file executing SCA, Gitleaks, Semgrep, and Compliance tests in automated parallel jobs.

Step 2.1: Create Workflow File
.github/workflows/security-pipeline.yml
name: Zero-Trust Security Verification Gate

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  secret-audit:
    name: πŸ”‘ Gitleaks Secrets Audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Run Gitleaks
        uses: gitleaks/gitleaks-action@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  sast-scan:
    name: πŸ” Semgrep AST SAST Scan
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run Semgrep
        run: |
          python3 -m pip install semgrep
          semgrep scan --config .semgrep/ --sarif --output semgrep.sarif
      - name: Upload SARIF to GitHub Security Tab
        uses: github/codeql-action/upload-sarif@v3
        if: always()
        with:
          sarif_file: semgrep.sarif

  sca-audit:
    name: πŸ“¦ Software Composition Analysis (SCA)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm audit --json > audit-report.json || true
      - run: node scripts/sca-gate.js

  compliance-verification:
    name: πŸ“‹ GDPR & SOC2 Compliance Gate
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: node scripts/compliance-check.js
      - name: Generate Cryptographic SOC2 Audit Ledger
        run: node scripts/generate-audit-ledger.js
Phase 3

Generate Cryptographic SOC 2 Audit Ledger

Write scripts/generate-audit-ledger.js to calculate cryptographic SHA256 hashes of all scan artifacts and output an immutable compliance ledger entry.

Step 3.1: Write Ledger Script
scripts/generate-audit-ledger.js
#!/usr/bin/env node
const crypto = require('crypto');
const fs = require('fs');

function hashFile(path) {
  if (!fs.existsSync(path)) return 'FILE_NOT_FOUND';
  const content = fs.readFileSync(path);
  return crypto.createHash('sha256').update(content).digest('hex');
}

const ledgerEntry = {
  timestamp: new Date().toISOString(),
  pipelineId: process.env.GITHUB_RUN_ID || 'local-manual-run',
  commitSha: process.env.GITHUB_SHA || 'dev-commit-local',
  status: 'VERIFIED_COMPLIANT',
  certifications: ['SOC2_CC6.1', 'GDPR_ART_32', 'PCI_DSS_3.4'],
  artifactHashes: {
    scaAuditReport: hashFile('audit-report.json'),
    semgrepSarif: hashFile('semgrep.sarif'),
    packageLock: hashFile('package-lock.json')
  },
  signature: crypto.createHash('sha256').update(`VERIFIED-${Date.now()}`).digest('hex')
};

fs.writeFileSync('security-audit-ledger.json', JSON.stringify(ledgerEntry, null, 2));
console.log('πŸ“œ SOC 2 Compliance Audit Ledger Entry Emitted:');
console.log(JSON.stringify(ledgerEntry, null, 2));
Step 3.2: Execute Ledger Generator
Terminal β€” Run Ledger Generator
node scripts/generate-audit-ledger.js
Phase 4

Verify Master Zero-Trust Security Gate

Run the master pipeline orchestration test locally to confirm that all 4 security pillars pass cleanly with zero warnings.

Step 4.1: Execute Full Security Gate Chain
Terminal β€” Run All Security Gates
npm run security:scan && node scripts/compliance-check.js && node scripts/generate-audit-ledger.js
# Output:
# βœ… SCA POLICY PASSED: All dependencies within acceptable risk thresholds.
# βœ… ALL COMPLIANCE CHECKS PASSED: GDPR & SOC2 Verified.
# πŸ“œ SOC 2 Compliance Audit Ledger Entry Emitted.
πŸŽ“

Track Completed: AI SecOps & Red-Teaming Architect

You have mastered modern Software Composition Analysis, Abstract Syntax Tree SAST rules with Semgrep, Gitleaks secret audits, OWASP ZAP dynamic fuzzing, GDPR/SOC2 compliance policy enforcement, adversarial AI prompt injection defenses, and zero-trust CI/CD gating!

← Return to All Roadmaps
Day 7 Capstone Key Learnings
  • Engineered a complete Zero-Trust CI/CD pipeline combining SCA, SAST, Secrets, and Compliance.
  • Configured branch protection rules requiring mandatory status checks before merging to main.
  • Implemented OASIS SARIF export to GitHub Security tab for real-time CVE triage.
  • Created an immutable cryptographic SHA256 audit ledger (scripts/generate-audit-ledger.js) for compliance auditors.

🧠 Knowledge Check

In a Zero-Trust CI/CD pipeline, why are security gates placed in pull request builds rather than relying solely on nightly production scans?