Lab 10: DevSecOps Pipeline

Time: 50 minutes | Level: Architect | Docker: docker run -it --rm zchencow/innozverse-cybersec:latest bash

Objectives

  • Design a complete DevSecOps pipeline with security gates

  • Run SAST with Bandit on vulnerable Python code

  • Understand DAST, SCA/SBOM, secret scanning, IaC scanning

  • Define security gates and break-build policies


Step 1: DevSecOps Pipeline Architecture

Developer → Git Push


┌─────────────────────────────────────────────────────────┐
│                  CI/CD PIPELINE                          │
│                                                         │
│  PRE-COMMIT        BUILD            TEST                │
│  ┌───────────┐  ┌──────────┐   ┌──────────────────┐   │
│  │Secret scan│  │SAST      │   │DAST (ZAP)        │   │
│  │(git-secrets│  │(Bandit,  │   │SCA/SBOM          │   │
│  │detect-sec)│  │Semgrep)  │   │Container scan    │   │
│  └───────────┘  └──────────┘   │IaC scan (checkov)│   │
│                                └──────────────────┘   │
│                                                         │
│  SECURITY GATES                                         │
│  ┌─────────────────────────────────────────────────┐   │
│  │ No CRITICAL CVEs │ No HIGH SAST │ No secrets    │   │
│  │ IaC compliant    │ SBOM attached │ DAST passing  │   │
│  └─────────────────────────────────────────────────┘   │
│              │                                          │
│              ▼                                          │
│         Deploy to                                       │
│    Staging → Production                                 │
└─────────────────────────────────────────────────────────┘

Step 2: SAST with Bandit

Vulnerable Python code:

Run Bandit:

📸 Verified Output (medium+ severity):


Step 3: Secret Scanning

Tools:

  • detect-secrets — pre-commit hook; entropy + pattern-based

  • trufflehog — git history scanning; finds secrets in commits

  • gitleaks — SAST for secrets in source code

  • GitHub Advanced Security — native secret scanning + push protection

Pre-commit config:

Common secret patterns detected:

💡 If a secret is committed to git, assume it's compromised — git history is permanent. Rotate immediately, then remove from history with git-filter-repo or BFG Repo Cleaner.


Step 4: SCA and SBOM

Software Composition Analysis (SCA):

  • Identifies open-source components and their CVEs

  • Tools: Snyk, OWASP Dependency-Check, Grype, Trivy (filesystem mode)

SBOM (Software Bill of Materials):

  • Machine-readable inventory of all components

  • Formats: SPDX, CycloneDX

  • Required by: US Executive Order 14028, PCI DSS 4.0, NIST SSDF

SBOM structure (CycloneDX):


Step 5: DAST — Dynamic Application Security Testing

OWASP ZAP (Zed Attack Proxy) modes:

Mode
Description
Use Case

Baseline scan

Spider + passive scan only

CI/CD quick check

Full scan

Spider + active scan

Staging environment

API scan

OpenAPI/Swagger spec scan

REST APIs

Ajax Spider

SPA support

React/Angular apps

ZAP baseline CI example:

Key DAST findings:

  • SQL injection (CWE-89)

  • XSS (CWE-79)

  • CSRF (CWE-352)

  • Insecure headers (X-Frame-Options, CSP, HSTS)

  • Sensitive data in URLs (query parameters)


Step 6: IaC Security Scanning with Checkov

Infrastructure as Code scanning:

Example findings:

Terraform secure example:


Step 7: Security Gates

Security gate policies:

Gate
Fail Condition
Action

SAST

Any HIGH/CRITICAL finding

Block merge

Secret scan

Any secret detected

Block merge + alert

SCA

CRITICAL CVE in direct deps

Block merge

Container scan

CRITICAL CVE in base image

Block deploy

IaC scan

Any CRITICAL checkov finding

Block deploy

DAST

HIGH finding in staging

Block prod deploy

SBOM

Missing or unsigned

Block deploy

GitHub Actions pipeline:


Step 8: Capstone — DevSecOps Maturity Model

Scenario: Scale DevSecOps across 20 development teams


Summary

Tool
Stage
Purpose

detect-secrets / gitleaks

Pre-commit

Secret detection

Bandit / Semgrep

SAST

Code security flaws

OWASP Dependency-Check

SCA

OSS CVEs

Syft + Grype

SBOM

Component inventory + CVEs

OWASP ZAP

DAST

Runtime vulnerability testing

Checkov / tfsec

IaC

Infrastructure misconfigurations

Trivy

Container

Image CVE scanning

Security gates

Pipeline

Break-build on policy violation

Last updated