How aslaf/vulnflask-secureci works
Project Type and Purpose
• This is a full‐stack application (a vulnerable Flask e-commerce demo) wrapped in a comprehensive DevSecOps pipeline.
• Purpose: showcase a secure-by-design CI/CD workflow that shifts left (code scans, threat modeling) and shifts right (DAST, IAST, runtime enforcement).
File Structure Analysis
• Top‐Level Directories:
• .github/workflows: CI/CD definitions for each security phase
• app/: Python/Flask web application + HTML templates + SQLite demo DB
• k8s/: Kubernetes manifests (Deployment, Service, OPA Gatekeeper policies)
• iac/: Terraform sample for cloud provisioning
• falco/: Falco runtime rule definitions
• observability/: (likely dashboards, metrics, future expansion)
• scripts/: helpers to aggregate reports and notify Slack
• threat_model/: STRIDE threat register + validator script
• tests/: pytest for basic Flask functionality
• Config & Reports: Dockerfile, requirements.txt, various SBOM and scanner JSON outputs under docs/ and root.
README Insights
• 10 security phases, each implemented as GitHub Actions workflows.
• Tools in pipeline: Bandit, Semgrep, pip-audit, Gitleaks, Syft, Trivy, Checkov, OWASP ZAP, custom IAST logger, Falco, OPA Gatekeeper.
• Deployment target: local k3d or AWS EKS, plus live demo on Render.
Diagramming the Architecture
a. Main Components
1. Developer Workstation (IDE + Git + Python env)
2. Source Repository (GitHub)
3. CI/CD Platform (GitHub Actions) with parallel/staged workflows:
• Threat Modeling Validator
• SAST/SCA/Secrets Scans
• Container SBOM & CVE Scans
• IaC Scans
• DAST (baseline & live)
• IAST Runtime Logging
• Runtime Policy Enforcement
4. Artifact Stores:
• Docker Image Registry (local k3d or cloud)
• GitHub Artifacts (JSON reports, HTML)
5. Infrastructure:
• Kubernetes Cluster (EKS/k3d) running Flask app
• Terraform‐provisioned cloud resources (S3, VPC, etc.)
6. Runtime Security:
• Falco DaemonSet + Rules
• OPA Gatekeeper + Constraint Templates
7. External/Dev Tools:
• OWASP ZAP container
• Slack/Webhook for notifications
b. Relationships & Data Flows
• Code push triggers GitHub Actions workflows in series/parallel.
• Scanning jobs read source, produce JSON/HTML artifacts.
• Container build pushes image to registry, scanned by Trivy/Syft.
• Deploy job applies Terraform (iac/) then kubectl apply k8s manifests.
• DAST live points to external LoadBalancer URL.
• IAST instrumentation in Flask container emits logs back to CI.
• Falco/OPA intercept syscalls/Pod creations in the cluster.
c. Architectural Patterns & Principles
• “Security as Code”: every control codified in pipelines & IaC
• Layered defense: code → container → infra → runtime
• GitOps for deployments, Immutable infra in Git
• Shift-Left (pre-merge) and Shift-Right (post-deploy) scans
d. Key Technologies & Frameworks
• Flask (app), SQLite (demo DB)
• GitHub Actions (CI/CD)
• Docker, Syft, Trivy (container/SBOM)
• Checkov, Terraform (IaC)
• Kubernetes (EKS/k3d), OPA Gatekeeper
• Falco (runtime)
• OWASP ZAP (DAST), custom IAST Python logger
• Python scripts for threat validation & report aggregation