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 scanning | SAST: Semgrep, CodeQL |
|---|---|
| Dependencies | SCA: Dependabot, Trivy, OSV-Scanner |
| Secrets | Gitleaks, push protection |
| Infrastructure code | Checkov, tfsec / Trivy config |
| Running app | DAST: OWASP ZAP |
| Framework | OWASP SAMM, NIST SSDF (SP 800-218) |
Step by step
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.
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.
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.
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.
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
- Start with fast, low-noise checks (secrets, dependencies) and add more over time
- Fail the build only on high-confidence, high-severity findings; report the rest
- Show results inside pull requests where developers already work
- Scan infrastructure code and container images, not just application code
- Track fix times and recurring issues to guide training
More in DevSecOps.
Packets
| No. | Time | Source | Destination | Protocol | Info | Size |
|---|