End-to-End DevSecOps Pipeline using Flask, Docker, GitHub Actions, Terraform, AWS EC2, Prometheus, Grafana and Security Scanning Tools.
SecureApp is a vulnerable Flask-based web application developed to demonstrate the implementation of an end-to-end DevSecOps pipeline. The project integrates secure software development practices by automating security testing, containerization, infrastructure provisioning, continuous deployment, and monitoring.
The pipeline uses GitHub Actions to automate security scans, Docker to package the application, Terraform to provision AWS EC2 infrastructure, and Prometheus with Grafana for monitoring. Multiple security tools including Bandit, Semgrep, Gitleaks, pip-audit, Trivy, and OWASP ZAP are integrated to identify vulnerabilities throughout the Software Development Life Cycle (SDLC).
This project demonstrates how security can be incorporated into every stage of application development, making it suitable for learning modern DevSecOps practices.
- π User Registration and Login Authentication
- π€ Secure File Upload Functionality
- π³ Dockerized Flask Application
- βοΈ Automated CI/CD Pipeline using GitHub Actions
- βοΈ Infrastructure Provisioning using Terraform
- π₯οΈ Automated Deployment on AWS EC2
- π Static Application Security Testing (Bandit, Semgrep)
- π Secret Detection using Gitleaks
- π¦ Dependency Vulnerability Scanning using pip-audit
- π‘οΈ Container Image Scanning using Trivy
- π Dynamic Application Security Testing (OWASP ZAP)
- π Monitoring with Prometheus
- π Visualization using Grafana
- π¨ Demonstration of OWASP Top 10 Vulnerabilities
| Category | Technologies |
|---|---|
| Programming Language | Python 3.12 |
| Framework | Flask |
| Database | SQLite |
| Containerization | Docker, Docker Compose |
| Version Control | Git, GitHub |
| CI/CD | GitHub Actions |
| Infrastructure as Code | Terraform |
| Cloud Platform | AWS EC2 |
| Monitoring | Prometheus, Grafana |
| Static Security Testing (SAST) | Bandit, Semgrep |
| Secret Scanning | Gitleaks |
| Dependency Scanning | pip-audit |
| Container Security | Trivy |
| Dynamic Security Testing (DAST) | OWASP ZAP |
SecureApp-Pipeline/
β
βββ .github/workflows/ # GitHub Actions CI/CD pipeline
βββ app/ # Flask application source code
βββ docs/ # Documentation
βββ monitoring/ # Prometheus & Grafana configuration
βββ security/ # Security scan reports
β βββ bandit/
β βββ semgrep/
β βββ gitleaks/
β βββ trivy/
β βββ zap/
βββ templates/ # HTML templates
βββ terraform/ # Infrastructure as Code
βββ Dockerfile
βββ docker-compose.yml
βββ requirements.txt
βββ README.md
The following diagram illustrates the complete SecureApp DevSecOps workflow from code commit to automated deployment and security validation.
- Developer pushes source code to GitHub.
- GitHub Actions automatically starts the CI/CD pipeline.
- Security scans are executed using:
- Bandit
- Semgrep
- Gitleaks
- pip-audit
- Trivy
- Docker image is built.
- Terraform provisions AWS EC2 infrastructure.
- SecureApp is automatically deployed on EC2 using SSH.
- OWASP ZAP performs Dynamic Application Security Testing (DAST).
- Prometheus collects application metrics.
- Grafana visualizes monitoring dashboards.
git clone https://github.com/30032003/SecureApp-Pipeline.git
cd SecureApp-Pipelinepython -m venv .venv
.venv\Scripts\activatepython3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtpython app.pyApplication will be available at:
http://localhost:5000
Build Docker Image
docker build -t secureapp .Run Container
docker run -d -p 5000:5000 --name secureapp secureappdocker-compose up --buildhttp://localhost:5000
Terraform is used to provision AWS EC2 infrastructure.
cd terraform
terraform init
terraform plan
terraform applyAfter successful deployment, Terraform outputs the EC2 Public IP and Public DNS.
GitHub Actions automatically connects to the EC2 instance via SSH and deploys the latest application.
The SecureApp project follows a DevSecOps approach by integrating multiple security tools into the CI/CD pipeline. Every code change pushed to the GitHub repository automatically triggers static security scans, dependency analysis, secret detection, container image scanning, and deployment. Dynamic Application Security Testing (DAST) is performed using OWASP ZAP against the deployed application.
| Tool | Category | Purpose |
|---|---|---|
| Bandit | SAST | Detects Python security vulnerabilities in source code |
| Semgrep | SAST | Performs static code analysis using security rules |
| Gitleaks | Secret Scanning | Detects hardcoded secrets, API keys, and credentials |
| pip-audit | Software Composition Analysis (SCA) | Identifies vulnerable Python dependencies |
| Trivy | Container Security | Scans Docker images for known vulnerabilities |
| OWASP ZAP | DAST | Performs Dynamic Application Security Testing against the deployed application |
Developer
β
βΌ
Git Push
β
βΌ
GitHub Actions
β
βββ Checkout Repository
βββ Install Dependencies
βββ Bandit Scan
βββ Semgrep Scan
βββ Gitleaks Scan
βββ pip-audit Scan
βββ Docker Build
βββ Trivy Scan
βββ Upload Security Reports
β
βΌ
Deploy to AWS EC2
β
βΌ
OWASP ZAP Dynamic Scan
β
βΌ
Live SecureApp Application
The pipeline automatically generates reports for:
- β Bandit Report
- β Semgrep Report
- β Gitleaks Report
- β pip-audit Report
- β Trivy Report
- β OWASP ZAP Report
These reports help identify security issues before and after deployment, enabling continuous security validation throughout the Software Development Life Cycle (SDLC).
The application is deployed on an AWS EC2 instance provisioned using Terraform. GitHub Actions automatically deploys the latest version of the application after successful security validation.
Deployment Workflow:
Developer
β
βΌ
GitHub Repository
β
βΌ
GitHub Actions
β
βΌ
Security Scans
β
βΌ
Docker Build
β
βΌ
Terraform Provisioned AWS EC2
β
βΌ
Automatic Deployment via SSH
β
βΌ
SecureApp Running on Docker
| Component | Technology |
|---|---|
| Cloud Provider | AWS |
| Compute Service | EC2 |
| Infrastructure as Code | Terraform |
| Deployment Method | GitHub Actions + SSH |
| Container Runtime | Docker |
The application exposes Prometheus metrics, which are collected and visualized through Grafana dashboards.
Monitoring Flow:
SecureApp Flask
β
βΌ
/metrics Endpoint
β
βΌ
Prometheus
β
βΌ
Grafana Dashboard
| Component | Purpose |
|---|---|
| Prometheus | Collects application metrics |
| Grafana | Visualizes metrics using dashboards |
| Flask Metrics | Exposes application metrics for monitoring |
The following workflow demonstrates how SecureApp follows DevSecOps principles from code development to deployment and monitoring.
Developer
β
βΌ
Develops SecureApp Features
β
βΌ
Pushes Code to GitHub Repository
β
βΌ
GitHub Actions CI/CD Pipeline Starts
β
βββ Checkout Repository
βββ Setup Python Environment
βββ Install Dependencies
βββ Run Bandit (SAST)
βββ Run Semgrep (SAST)
βββ Run Gitleaks (Secret Scanning)
βββ Run pip-audit (Dependency Scanning)
βββ Build Docker Image
βββ Run Trivy (Container Scanning)
βββ Upload Security Reports
β
βΌ
Terraform Infrastructure
β
βΌ
AWS EC2 Instance
β
βΌ
SSH Deployment
β
βΌ
Docker Container
β
βΌ
SecureApp Running
β
βΌ
OWASP ZAP Scan (DAST)
β
βΌ
Prometheus Monitoring
β
βΌ
Grafana Dashboard
The developer implements new features or security improvements and pushes the latest code to the GitHub repository.
GitHub Actions automatically starts the CI pipeline.
During this stage:
- Source code is checked out.
- Python dependencies are installed.
- Security tools are executed.
- Docker image is built.
- Security reports are generated.
Terraform provisions the AWS infrastructure required to host the application.
Resources include:
- AWS EC2 Instance
- Security Group
- User Data Script
After successful validation, GitHub Actions connects to the EC2 instance through SSH.
Deployment process:
- Pull latest source code
- Build Docker image
- Stop existing container
- Deploy updated container
OWASP ZAP performs Dynamic Application Security Testing (DAST) against the deployed application to identify runtime web security vulnerabilities.
Prometheus continuously collects metrics from the application.
Grafana visualizes:
- Application Health
- Metrics
- Monitoring Dashboards
This enables continuous monitoring of the deployed application.
The following enhancements can further improve the project:
- Deploy using Kubernetes (Amazon EKS)
- Implement Helm Charts for application deployment
- Integrate SonarQube for Code Quality Analysis
- Configure Slack or Microsoft Teams notifications
- Add HTTPS using Nginx Reverse Proxy and Let's Encrypt
- Implement Auto Scaling and Load Balancer
- Store Docker images in Amazon ECR
- Deploy using Amazon ECS or Kubernetes
- Integrate SIEM solutions for centralized log monitoring
- Implement automated backup and disaster recovery strategy
This project provided practical experience with:
- Secure Software Development Lifecycle (SSDLC)
- DevSecOps principles and practices
- Infrastructure as Code (Terraform)
- Continuous Integration and Continuous Deployment (CI/CD)
- Static Application Security Testing (SAST)
- Dynamic Application Security Testing (DAST)
- Software Composition Analysis (SCA)
- Container Security
- Cloud Deployment using AWS
- Monitoring and Observability using Prometheus & Grafana
Harshal Dahiwale
- GitHub: https://github.com/30032003
- LinkedIn: https://www.linkedin.com/in/harshal-dahiwale-02610a22a/
If you found this project useful, consider giving it a β on GitHub.
This project is licensed under the MIT License.
This project was developed as part of the PG-DITISS (Post Graduate Diploma in IT Infrastructure, Systems & Security) program at CDAC ACTS, Pune. It demonstrates the implementation of modern DevSecOps practices using open-source technologies and cloud infrastructure.














