Skip to content

Repository files navigation

πŸ” SecureApp Pipeline

End-to-End DevSecOps Pipeline using Flask, Docker, GitHub Actions, Terraform, AWS EC2, Prometheus, Grafana and Security Scanning Tools.

Python Flask Docker GitHub Actions Terraform AWS Prometheus Grafana Trivy License


πŸ“– Project Overview

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.

πŸš€ Features

  • πŸ” 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

πŸ› οΈ Technology Stack

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

πŸ“‚ Project Structure

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

πŸ—οΈ Architecture Diagram

The following diagram illustrates the complete SecureApp DevSecOps workflow from code commit to automated deployment and security validation.

Pipeline Flow

  1. Developer pushes source code to GitHub.
  2. GitHub Actions automatically starts the CI/CD pipeline.
  3. Security scans are executed using:
    • Bandit
    • Semgrep
    • Gitleaks
    • pip-audit
    • Trivy
  4. Docker image is built.
  5. Terraform provisions AWS EC2 infrastructure.
  6. SecureApp is automatically deployed on EC2 using SSH.
  7. OWASP ZAP performs Dynamic Application Security Testing (DAST).
  8. Prometheus collects application metrics.
  9. Grafana visualizes monitoring dashboards.

πŸš€ Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/30032003/SecureApp-Pipeline.git
cd SecureApp-Pipeline

2️⃣ Create Virtual Environment

Windows

python -m venv .venv
.venv\Scripts\activate

Linux/macOS

python3 -m venv .venv
source .venv/bin/activate

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Run the Application

python app.py

Application will be available at:

http://localhost:5000

5️⃣ Run using Docker

Build Docker Image

docker build -t secureapp .

Run Container

docker run -d -p 5000:5000 --name secureapp secureapp

6️⃣ Run using Docker Compose

docker-compose up --build

7️⃣ Access the Application

http://localhost:5000

βš™οΈ Infrastructure Deployment

Terraform is used to provision AWS EC2 infrastructure.

cd terraform

terraform init

terraform plan

terraform apply

After 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.

πŸ”’ DevSecOps Security Pipeline

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

πŸ”„ CI/CD Security Workflow

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

πŸ“„ Security Reports

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).

☁️ Deployment & Monitoring

AWS Deployment

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

Infrastructure

Component Technology
Cloud Provider AWS
Compute Service EC2
Infrastructure as Code Terraform
Deployment Method GitHub Actions + SSH
Container Runtime Docker

Monitoring Stack

The application exposes Prometheus metrics, which are collected and visualized through Grafana dashboards.

Monitoring Flow:

SecureApp Flask
        β”‚
        β–Ό
 /metrics Endpoint
        β”‚
        β–Ό
 Prometheus
        β”‚
        β–Ό
 Grafana Dashboard

Monitoring Components

Component Purpose
Prometheus Collects application metrics
Grafana Visualizes metrics using dashboards
Flask Metrics Exposes application metrics for monitoring

πŸ”„ End-to-End Project Workflow

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

Workflow Explanation

1. Source Code Management

The developer implements new features or security improvements and pushes the latest code to the GitHub repository.


2. Continuous Integration (CI)

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.

3. Infrastructure Provisioning

Terraform provisions the AWS infrastructure required to host the application.

Resources include:

  • AWS EC2 Instance
  • Security Group
  • User Data Script

4. Continuous Deployment (CD)

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

5. Dynamic Security Testing

OWASP ZAP performs Dynamic Application Security Testing (DAST) against the deployed application to identify runtime web security vulnerabilities.


6. Monitoring

Prometheus continuously collects metrics from the application.

Grafana visualizes:

  • Application Health
  • Metrics
  • Monitoring Dashboards

This enables continuous monitoring of the deployed application.

πŸ“Έ Project Screenshots

GitHub Repository

GitHub Repository


GitHub Actions CI/CD Pipeline

GitHub Actions


AWS EC2 Deployment

AWS EC2


SecureApp Login Page

Login


User Registration

Register


User Profile

Profile


File Upload

Upload


Terraform Infrastructure Deployment

Terraform


Prometheus Monitoring

Prometheus


Grafana Dashboard

Grafana


Bandit Security Report

Bandit


Semgrep Security Report

Semgrep


Trivy Container Scan

Trivy


OWASP ZAP Dynamic Security Scan

OWASP ZAP

πŸš€ Future Enhancements

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

πŸ“š Learning Outcomes

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

πŸ‘¨β€πŸ’» Author

Harshal Dahiwale

If you found this project useful, consider giving it a ⭐ on GitHub.

πŸ“„ License

This project is licensed under the MIT License.

πŸ™ Acknowledgements

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.

About

Secure Flask application with an end-to-end DevSecOps pipeline using GitHub Actions, Docker, Terraform, AWS EC2, Prometheus, Grafana and automated security scanning.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages