Case study · Security & compliance
DevSecOps CI/CD Pipeline
A delivery pipeline for a FastAPI service that scans code, dependencies, images and infrastructure, signs the image, and lets only signed images run on EKS.
How it fits together
- Commit
- flake8, black, isort
- unit tests + coverage
- Scan
- Semgrep (SAST, SARIF)
- Trivy (Dockerfile + image)
- Checkov (Terraform + K8s)
- Build
- multi-arch image
- push to ECR
- Cosign keyless signature
- SLSA provenance
- Deploy (EKS)
- OPA Gatekeeper policies
- rollout + health check
- Prometheus alerts
The problem
Security reviews done by hand at the end of a release are slow and miss things. The goal was a pipeline where each check runs on every change and the cluster refuses anything that did not pass.
What I built
- A build workflow: lint, format and import checks, unit tests with coverage, multi-arch Docker build, push to Amazon ECR.
- Semgrep SAST with results uploaded as SARIF to GitHub code scanning, and the job fails on findings (--error).
- Trivy scans of the Dockerfile and the image, and Checkov scans of the Terraform and Kubernetes files.
- Keyless image signing with Cosign and build provenance with actions/attest-build-provenance.
- Six OPA Gatekeeper policies: require signed images, block privilege escalation, block hostPath and hostNetwork, require resource limits, block the default service account, and require namespace labels.
- External Secrets for secrets, and Prometheus alerts and a Grafana dashboard for Gatekeeper violations.
Decisions
- Keyless signing (Cosign with the GitHub OIDC identity), so there is no long-lived signing key to store or rotate.
- Enforcement in the cluster as well as in CI: Gatekeeper blocks a workload that skips the pipeline.
What went wrong: Where the gates are soft
A review of the workflows found that Checkov runs with --soft-fail, so a Terraform or Kubernetes misconfiguration is reported but does not stop the build. The PRD targets (for example 95% fewer vulnerabilities in production) are goals, not measured results, so they are not quoted as results here.
What I would improve next
- Make Checkov block on high-severity findings, with a baseline file for accepted risks.
- Expand the 70-word README: what each workflow does, the gate order, and how to run it.
- Move prd.md and task-list.md into docs/ so the repository root shows the product, not the planning.