Skip to content

Paulinhx/secure-sbom-supplychain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔐 Secure Supply Chain with Flask, SBOM & Cosign

This project demonstrates how to secure container images using:

  • Syft for generating a Software Bill of Materials (SBOM)
  • Cosign for signing and verifying image authenticity
  • GitHub Actions for automating image scanning and signing

The goal is to give you a production-style setup for image trust and visibility — using an intentionally simple Flask app as the base.


📦 What’s Inside

  • A Python Flask app containerized via Docker
  • SBOM generated from the built image
  • Container image signed with Cosign
  • GitHub Actions pipeline that builds, scans, and signs on push

📁 Project Structure

secure-sbom-supplychain/
├── app/
│   └── main.py                # Flask application
├── Dockerfile                 # Defines the image
├── cosign.pub                 # Public key for signature verification
├── sbom.spdx.json             # SBOM output (example/demo)
├── .github/
│   └── workflows/
│       └── supplychain.yml    # CI: SBOM + Sign image
├── .gitignore
└── README.md

🚀 How It Works

🐍 1. Flask Application

The app is served from a minimal Flask setup to simulate a deployable API. It's mounted in a Python 3.11 Docker container.

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Secure SBOM Demo"

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000)

🐳 2. Dockerfile

FROM python:3.11-slim
WORKDIR /app
COPY app/ /app/
RUN pip install flask
EXPOSE 5000
CMD ["python", "main.py"]

🧪 3. Generate an SBOM Locally (Optional)

Install Syft:

docker build -t sbom-demo-app .
syft sbom-demo-app -o spdx-json > sbom.spdx.json

🔐 4. Sign Image with Cosign

Install Cosign:

COSIGN_PASSWORD="" cosign generate-key-pair
cosign sign --key cosign.key sbom-demo-app

Only commit cosign.pub (public key).


🛡️ 5. Verify Image Signature

cosign verify --key cosign.pub sbom-demo-app

⚙️ GitHub Actions: supplychain.yml

The workflow automatically:

  • Builds the Docker image
  • Generates an SBOM with Syft
  • Signs the image with Cosign (using a key stored as a GitHub secret)
env:
  COSIGN_PASSWORD: ""
  COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}

🧠 Why It Matters

This project emulates modern supply chain security practices, including:

  • Transparency of dependencies (SBOM)
  • Artifact integrity (Cosign)
  • CI-integrated trust policies

👨‍💻 Author

Paul D.
Security Automation Engineer
🔗 github.com/Paulinhx

About

End-to-end supply chain security demo using Flask, Syft (SBOM), Cosign (image signing), and GitHub Actions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors