A fully automated, enterprise-grade CI/CD pipeline with security baked in at every stage — secrets scanning, dependency auditing, SAST, DAST, container scanning, SBOM generation, 3-environment deployment with manual approval gate, and real-time stage-level Slack alerts.
- Overview
- Pipeline in Action
- Architecture
- Pipeline Stages
- 3-Environment Deployment
- Security Tools
- Project Structure
- Setup & Installation
- Slack Notifications
- Contributing
This project implements a DevSecOps CI/CD pipeline that integrates security scanning seamlessly into the software delivery lifecycle. Security is not an afterthought — it is embedded at every stage of the pipeline.
Every push to the repository automatically triggers:
- 🔑 Secrets scanning — Gitleaks detects any leaked credentials
- 🐍 Dependency scanning — pip-audit checks for CVEs in Python packages
- 🔍 SAST — Bandit + SonarCloud perform deep static code analysis
- 🌐 DAST — OWASP ZAP full-scan for runtime vulnerabilities
- 🐳 Build, Push & Scan — Docker image built, scanned with Trivy, SBOM generated
- 🟡 Deploy to Staging — Auto-deploy on every commit
- 🟠 Deploy to Pre-prod — Auto-deploy after staging passes
- ⏸️ Manual Approval Gate — Human review required before production
- 🟢 Deploy to Production — Final deployment after approval
- 📣 Stage-level Slack alerts — Real-time pass/fail notifications per stage
- 🤖 Dependabot — Automated weekly dependency update PRs
All stages passed — Gitleaks ✅ · pip-audit ✅ · Bandit ✅ · SonarCloud ✅ · OWASP ZAP ✅ · Trivy ✅ · SBOM ✅ · Staging ✅ · Pre-prod ✅ · Production ✅
Quality Gate: Passed · Open Issues: 0 · Duplications: 0.0% · Coverage: 99.4% · Security Rating: A
The
devsecops-botsends instant Slack notifications per stage — success or failure — with commit info and direct links.
Full pipeline passing all stages with manual approval gate for production deployment.
Developer Push / Pull Request
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ GitHub Actions CI/CD │
│ │
│ ┌──────────┐ ┌───────────┐ ┌──────────────┐ ┌────────┐ ┌──────────┐ │
│ │ Gitleaks │─▶│ pip-audit │─▶│Bandit+Sonar │─▶│OWASPZap│─▶│Build+ │ │
│ │ Secrets │ │ Dep Scan │ │ SAST │ │ DAST │ │Trivy+SBOM│ │
│ └──────────┘ └───────────┘ └──────────────┘ └────────┘ └──────────┘ │
│ │ │
│ ┌─────────────────────────────────────────────────────▼──────┐ │
│ │ 🟡 Staging → 🟠 Pre-prod → ⏸️ Manual Approval → 🟢 Prod │ │
│ └────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ Stage-Level Slack Alerts (each job) │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
Scans the entire git history for leaked API keys, passwords, tokens, or credentials.
- name: Gitleaks secrets scan
uses: gitleaks/gitleaks-action@v2Result: No leaks detected ✅
Audits all Python dependencies in requirements.txt against the PyPI Advisory Database for known CVEs.
- name: Run pip-audit
run: pip-audit -r app/requirements.txt --format=json --output=pip-audit-report.jsonReport uploaded as downloadable artifact on every run ✅
Bandit — Python-specific static security analysis:
- name: Run Bandit SAST Scan
run: bandit -r app/ -f json -o bandit-report.json --exit-zeroSonarCloud — Deep static analysis for bugs, security hotspots, and code smells:
- Quality Gate: Passed
- Security Issues: 0
- Code Coverage: 99.4%
- Security Rating: A
Actively attacks the running application to find vulnerabilities like XSS, SQL injection, and misconfigurations.
- name: OWASP ZAP Scan
uses: zaproxy/action-full-scan@v0.10.0138 checks PASS · 0 FAIL ✅
Builds the Docker image, scans with Trivy, generates an SBOM with Syft, pushes to Docker Hub.
docker build -t devsecops-app .
trivy image devsecops-app # CVE scan
syft devsecops-app # SBOM generation
docker push vivek1251/devsecops-appBuild & Scan
│
▼
🟡 Staging (auto) → my-cicd-server port 5001
│
▼
🟠 Pre-prod (auto) → cicd-server port 5000
│
▼
⏸️ Manual Approval Gate → vivek1251 must approve
│
▼
🟢 Production (approved) → devsecops-server port 5000
| Environment | Server | Trigger |
|---|---|---|
| 🟡 Staging | my-cicd-server | Auto on every commit |
| 🟠 Pre-prod | cicd-server | Auto after staging passes |
| 🟢 Production | devsecops-server | Manual approval required |
| Tool | Type | Purpose | Stage |
|---|---|---|---|
| Gitleaks | Secrets Scan | Detects leaked credentials in git history | Pre-build |
| pip-audit | Dependency Scan | CVE scanning of Python packages | Pre-build |
| Bandit | SAST | Python-specific static security analysis | Pre-build |
| SonarCloud | SAST | Static code quality & security analysis | Pre-build |
| OWASP ZAP | DAST | Full active runtime vulnerability testing | Post-deploy |
| Trivy | Container Scan | Docker image CVE scanning | Post-build |
| Syft | SBOM | Software Bill of Materials generation | Post-build |
| Dependabot | Dependency Updates | Automated weekly PRs for outdated packages | Scheduled |
| Slack Bot | Alerting | Stage-level real-time notifications | All stages |
devsecops-pipeline/
├── .github/
│ ├── workflows/
│ │ └── deploy.yml # Main CI/CD pipeline
│ └── dependabot.yml # Automated dependency updates
├── app/
│ ├── app.py # Python Flask application
│ ├── test_app.py # Unit tests (99.4% coverage)
│ ├── Dockerfile # Container definition
│ └── requirements.txt # Python dependencies
├── .env.example # Required environment variables
├── CONTRIBUTING.md # Contribution guidelines
├── LICENSE # MIT License
├── sonar-project.properties # SonarCloud configuration
└── README.md
- Python 3.x
- Docker
- GitHub account
- SonarCloud account
- AWS EC2 instances (3 for full environment setup)
- Slack workspace
# 1. Clone the repository
git clone https://github.com/vivek1251/devsecops-pipeline.git
cd devsecops-pipeline
# 2. Copy env example and fill in values
cp .env.example .env
# 3. Install dependencies
pip install -r app/requirements.txt
# 4. Run tests
pytest app/ --cov=app
# 5. Run Bandit locally
pip install bandit
bandit -r app/
# 6. Build Docker image
docker build -t devsecops-app ./app
# 7. Scan with Trivy
trivy image devsecops-appSet these in Settings → Secrets → Actions:
| Secret | Description |
|---|---|
SONAR_TOKEN |
SonarCloud authentication token |
DOCKER_USERNAME |
Docker Hub username |
DOCKER_PASSWORD |
Docker Hub password |
STAGING_HOST |
Staging EC2 public IP |
STAGING_USERNAME |
Staging EC2 SSH username |
STAGING_KEY |
Staging EC2 private SSH key |
PREPROD_HOST |
Pre-prod EC2 public IP |
PREPROD_USERNAME |
Pre-prod EC2 SSH username |
PREPROD_KEY |
Pre-prod EC2 private SSH key |
EC2_HOST |
Production EC2 public IP |
EC2_USERNAME |
Production EC2 SSH username |
EC2_KEY |
Production EC2 private SSH key |
SLACK_WEBHOOK |
Slack incoming webhook URL |
The pipeline sends stage-level real-time Slack alerts:
| Stage | Alert |
|---|---|
| 🔑 Gitleaks | ❌ Secret detected in code |
| 🐍 pip-audit | ❌ Vulnerable dependency found |
| 🔍 SAST | ❌ Bandit or SonarCloud Quality Gate failed |
| 🌐 DAST | ❌ OWASP ZAP found critical vulnerabilities |
| 🐳 Trivy | ❌ CRITICAL/HIGH CVE in Docker image |
| 🟡 Staging | ✅ Staging deployed successfully |
| 🟠 Pre-prod | ✅ Pre-prod deployed, awaiting approval |
| 🚀 Production | ✅ Full pipeline passed, production deployed |
| Feature | Effort |
|---|---|
| Pipeline metrics dashboard | Advanced |
| Feature | Status |
|---|---|
| 3-environment deploy (staging → preprod → prod) | ✅ Done |
| Manual approval gate for production | ✅ Done |
| OWASP ZAP full-scan (vs baseline) | ✅ Done |
| Dependabot auto-PRs for dependency updates | ✅ Done |
| Vigilant mode (commit verification) | ✅ Done |
| pip + Docker layer caching | ✅ Done |
| Stage-level Slack alerts | ✅ Done |
| Branch protection on main | ✅ Done |
| SBOM generation with Syft | ✅ Done |
| Bandit SAST scanning | ✅ Done |
| pip-audit dependency scanning | ✅ Done |
See CONTRIBUTING.md for full guidelines.
- Fork the repository
- Create a feature branch:
git checkout -b feat/your-feature - Commit your changes:
git commit -m 'feat: add your feature' - Push to the branch:
git push origin feat/your-feature - Open a Pull Request into
main— all pipeline checks must pass
Made with ❤️ by vivek1251



