Skip to main content

SBOMPY: API-triggered SBOM generator for running Docker workloads (SAND5G-oriented).

Project description

SBOMPY

About

This Python package was developed in the SAND5G project, which aims to enhance security in 5G networks.

SBOMPY is a Python-based, FastAPI service that can be triggered via HTTP to generate SBOMs for the Docker workloads currently running on a host. It is designed for platform-style deployments where verticals are deployed as containers and must be scanned and recorded as part of the operational flow.

Repository: https://github.com/ISSG-UPAT/SBOMPY
Project Website: https://sand5g-project.eu
SAND5G

Overview

SBOMPY runs as a container and connects to the host Docker daemon via the Docker socket. When triggered, it discovers eligible containers, resolves their image identifiers (preferably digests), and generates SBOMs using an external tool backend (syft or trivy). Outputs are persisted under /data for later ingestion by the platform.

Features

  • RESTful API with FastAPI for SBOM generation
  • Asynchronous job processing with background workers
  • Container discovery with filtering capabilities
  • SBOM generation using Syft or Trivy backends
  • Deduplication via digest-based caching
  • Persistent storage with SQLite database
  • Production hardening features
  • API key authentication (optional)

API Endpoints

  • GET /health - Health check
  • POST /sbom/discover - Preview containers to be scanned
  • POST /sbom/run - Start async SBOM generation job
  • GET /jobs/{job_id} - Poll job status and results
  • GET /jobs - List recent jobs
  • GET /sbom/artifacts - List all SBOM artifacts
  • GET /sbom/artifacts/{run_id} - Get specific run artifacts

Requirements

  • Python 3.11+
  • Docker access via socket mount: /var/run/docker.sock:/var/run/docker.sock
  • For Docker deployment: persistent volume mount for /data

Quick Start

Using Docker Compose (Recommended)

git clone https://github.com/ISSG-UPAT/SBOMPY.git
cd SBOMPY
make compose-up

The service will be available at http://localhost:8080.

Development Setup

git clone https://github.com/ISSG-UPAT/SBOMPY.git
cd SBOMPY
make setup-all-dev
make test
sbompy

This creates a virtual environment, installs all dependencies, runs tests, and starts the server.

Installation

From Source

git clone https://github.com/ISSG-UPAT/SBOMPY.git
cd SBOMPY
pip install .

Development Installation

pip install -e .[dev,docs]

Using Makefile

The project includes a comprehensive Makefile for development:

make help                    # Show all available targets
make setup-all-dev          # Create venv + install all dependencies
make test                   # Run tests
make doc-pdoc               # Generate documentation
make docker-build           # Build Docker image

Configuration

SBOMPY is configured via environment variables:

Variable Default Description
SBOMPY_HOST 0.0.0.0 Server host
SBOMPY_PORT 8080 Server port
SBOMPY_API_KEY - Optional API key for authentication
SBOMPY_WORKERS 2 Number of background workers
SBOMPY_TOOL_DEFAULT syft Default SBOM tool
SBOMPY_FORMAT_DEFAULT syft-json Default output format

Filtering and Allow-lists

Container discovery uses Docker labels for filtering:

  • Allow-list label: sand5g.managed=true (default)
  • Namespace label: sand5g.namespace=<vertical>

Usage Examples

Health Check

curl http://localhost:8080/health

Discover Containers

curl -X POST http://localhost:8080/sbom/discover \
  -H 'Content-Type: application/json' \
  -d '{"filters":{"compose_project":"open5gs","require_label_key":"sand5g.managed","require_label_value":"true"}}'

Generate SBOMs

curl -X POST http://localhost:8080/sbom/run \
  -H 'Content-Type: application/json' \
  -d '{"tool":"syft","format":"cyclonedx-json","filters":{"namespace":"vertical-a"}}'

Check Job Status

curl http://localhost:8080/jobs/{job_id}

Development

Running Tests

make test
# or
pytest

Code Quality

# Lint with ruff
ruff check .

# Format code
ruff format .

Documentation

# Generate API docs with pdoc
make doc-pdoc

# Host docs locally
make doc-pdoc-host

FastAPI automatic docs are available at http://localhost:8080/docs.

Docker Deployment

Build Images

make docker-build          # Standard image
make docker-build-alpine   # Alpine-based image
make docker-build-modified # Modified image (used in compose)

Docker Compose

The included docker-compose.yml provides a production-ready setup with:

  • Persistent data volume
  • Security hardening (read-only, dropped capabilities)
  • Docker socket access for container scanning
make compose-up    # Start services
make compose-down  # Stop services

Project Structure

├── src/sbompy/              # Main package
│   ├── api.py             # FastAPI application
│   ├── auth.py            # Authentication middleware
│   ├── cache.py           # Digest-based caching
│   ├── db.py              # SQLite database operations
│   ├── docker_client.py   # Docker API client
│   ├── jobs.py            # Background job processing
│   ├── main.py            # Application entry point
│   ├── models.py          # Pydantic models
│   ├── storage.py         # File storage operations
│   └── tools.py           # SBOM tool integrations
├── docker/                # Docker configurations
├── docs/                  # Documentation
├── tests/                 # Test suite
└── pyproject.toml         # Project configuration

License

MIT License - see LICENSE file for details.

Copyright (c) 2026 ISSG University of Patras

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Run make test to ensure everything works
  6. Submit a pull request

Issues and pull requests are welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sbompy-0.1.0.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sbompy-0.1.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file sbompy-0.1.0.tar.gz.

File metadata

  • Download URL: sbompy-0.1.0.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for sbompy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3fb1f2defb355966816232e00d4040c802b8f2d61363eefa049e6f689b4f6b40
MD5 91c110a0dfbe78e05e1b1cb0d4396aca
BLAKE2b-256 cc2a9b082d62da81fd8a6eb5af9ceb0ce048be82d057fd450b62eda6a1e97382

See more details on using hashes here.

File details

Details for the file sbompy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sbompy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for sbompy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68322e495cd93ead9e2ce24fa98db5ea9391f1e0514cfa48e10b6c3a4a051e50
MD5 266594acb276d9e4884f9a49b43373be
BLAKE2b-256 7209d0c1a1223ac92dfe91698c8a450a7472d5da69753c25d5c81cfa472650b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page