Build the SBOM from a lock:
poetry.lock,Pipfile.lockor a fully pinnedrequirements.txt. Arequirements.txtwith ranges (>=) or only your direct packages is not enough, because it doesn't say which versions you ship. Watch development dependencies: Pipfile.lock separates them, but since Poetry 1.5poetry.lockno longer says which group a package belongs to.
Which file the SBOM comes from
| Package manager | File | Full dependency tree? | Dev dependencies left out? |
|---|---|---|---|
| pip | requirements.txt (lines pinned with ==) | Only if it lists everything (pip freeze, pip-compile) | No such concept: keep dev packages in a different file |
| Poetry | poetry.lock | Yes | Only in lockfiles from Poetry before 1.5 (category = "dev"). Since 1.5, groups aren't written to the lock |
| Pipenv | Pipfile.lock | Yes | Yes: the develop section |
How to generate it
With the CRA Starter Kit tool
normavio_sbom.py reads the three files, skips .venv and venv, and writes a readable report next to the SBOM. From requirements.txt it only takes lines pinned with ==.
python3 normavio_sbom.py ./service \
--name "Nimbus Cloud API" --version 2.0.0 \
--osv --out ./technical-file/sbom/2.0.0
# -> sbom.cdx.json and sbom-report.md Poetry 1.5 or later: export the main group first
Because poetry.lock no longer marks dev groups, export only what you ship and point the tool at that file. On Poetry 2, export comes from the poetry-plugin-export plugin.
poetry export --only main --without-hashes \
-f requirements.txt -o sbom-input/requirements.txt
python3 normavio_sbom.py ./sbom-input --name "Nimbus Cloud API" --version 2.0.0 A fully pinned requirements.txt with pip
If you use plain pip, freeze a clean virtual environment that has only your production packages installed. pip-tools (pip-compile) gives you the same from a short list of direct dependencies.
python3 -m venv /tmp/prod
/tmp/prod/bin/pip install -r requirements.in # your direct dependencies
/tmp/prod/bin/pip freeze > requirements.txt With the official CycloneDX tool
pip install cyclonedx-bom gives you cyclonedx-py, with subcommands for an installed environment, requirements files, Poetry and Pipenv. Run it against an environment that holds only your production packages.
What catches teams out
- Poetry 1.5 and later. If pytest, ruff or mypy appear as components, this is why. Use the export step above.
- Ranges in requirements.txt.
requests>=2.31is skipped by the kit's tool and is useless to anyone else: it doesn't say what you shipped. - Several requirements.txt in the repo (for example
docs/requirements.txt). Generators scan the whole folder, so point them at the service you ship. The kit's tool reads only files named exactlyrequirements.txt, sorequirements-dev.txtis ignored. - What pip doesn't see. The Python interpreter and system libraries such as OpenSSL aren't in any Python lockfile. If you ship them (a container image, an appliance), scan the image too.
What the CRA asks of this SBOM
- Identify and document the components, including by drawing up an SBOM in a commonly used, machine-readable format, covering at least the top-level dependencies (Annex I, Part II, point 1).
- Keep it in the technical documentation, one per product version (Annex VII, point 2).
- Use it to find and fix vulnerabilities in those components without delay (Annex I, Part II, point 2).
The SBOM guide covers formats, fields and how to keep it alive.
Frequently asked questions
Is a requirements.txt with only my direct dependencies enough for the CRA?
It covers the legal minimum (top-level dependencies) only if the versions are pinned. In practice, pin the full tree with pip freeze or pip-compile: vulnerabilities are usually in transitive packages.
Do I list packages from extras?
List what you install in the product you place on the market. If an extra is installed there, its packages are components; if not, leave them out.
Does a Docker image change anything?
Yes. The image also ships the interpreter and operating system packages. Generate an SBOM of the image (Syft and Trivy read images) as well as the one from your lockfile.