Secure CI/CD Pipeline

Security checks from commit to production

DevSecOps builds security checks into the same automated pipeline that builds, tests and deploys code. Each stage catches a different kind of problem early, when it's cheapest to fix, without slowing developers down with manual gates.

Beginner · 5 steps

Code scanningSAST: Semgrep, CodeQL
DependenciesSCA: Dependabot, Trivy, OSV-Scanner
SecretsGitleaks, push protection
Infrastructure codeCheckov, tfsec / Trivy config
Running appDAST: OWASP ZAP
FrameworkOWASP SAMM, NIST SSDF (SP 800-218)

Step by step

  1. Before the commit Pre-commit secret scanning

    A pre-commit hook scans changes on the developer's machine. It spots an API key pasted into a config file and blocks the commit before it ever leaves the laptop. The repository also has push protection as a second safety net.

  2. Pull request checks SAST and dependency scanning

    Opening a pull request starts the pipeline. Static analysis (SAST) reads the code and flags a SQL query built from user input. Software composition analysis (SCA) checks dependencies and finds a library with a known critical vulnerability. Both show up as comments on the pull request.

  3. Infrastructure and image checks IaC and container scanning

    The same pull request changes Terraform. The IaC scanner flags a security group that opens SSH to the whole internet. After the build, the container image is scanned for vulnerable OS packages, and only images that pass are signed and pushed to the registry.

  4. Test the running app DAST in staging

    The new version is deployed to staging, where a dynamic scanner (DAST) tests it from the outside like an attacker would: missing security headers, cookie flags, reflected input. It reports a missing Content-Security-Policy header, which becomes a ticket rather than a blocker.

  5. Deploy with guardrails Only verified images reach production

    Production only accepts images that are signed by the pipeline and passed the scans. An admission policy checks the signature at deploy time, and runtime monitoring watches for anything unusual. Security became part of the normal flow, not a separate phase at the end.

Best practices

More in DevSecOps.