Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 123Security · Supply chain

How to create an SBOM for an image

When the next Log4Shell comes, the question is: which of our images contain the bad library? A Software Bill of Materials (SBOM) is the ingredient list of an image — every package and version. With SBOMs stored for each release you answer in minutes, not days. This how-to creates an SBOM with Syft, chooses the format, scans it for vulnerabilities later, and attaches it to the image.

  • 5 Lessen
  • 8 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

123.1

The quick answer

syft registry.example.com/shop/api:1.4.2 -o cyclonedx-json=sbom.cdx.json
syft registry.example.com/shop/api:1.4.2 -o table | head
grype sbom:sbom.cdx.json

Syft makes the list; Grype (or Trivy) checks the list for known CVEs — also months later, without the image.

123.2

Step by step

  1. Install Syft (and Grype) — see the full guides, or run them as containers.
  2. Make the SBOM of an image, a folder or an archive:
syft registry.example.com/shop/api:1.4.2 -o cyclonedx-json=sbom.cdx.json -o spdx-json=sbom.spdx.json
syft dir:. -o cyclonedx-json=sbom-src.cdx.json
  1. Choose the format:
FormatUse
CycloneDX JSONSecurity tools, Dependency-Track, most scanners.
SPDX JSONLicenses, legal and government requirements.
tableQuick look for people.
  1. Find a library fast — the "are we affected?" question:
syft registry.example.com/shop/api:1.4.2 -o table | grep -i log4j
jq -r '.components[] | select(.name=="openssl") | .name + " " + .version' sbom.cdx.json
  1. Scan the SBOM now and later (new CVEs appear every day):
grype sbom:sbom.cdx.json --only-fixed --fail-on high
trivy sbom sbom.cdx.json
  1. Keep it with the image — store it as a build artifact and/or attach it as a signed attestation:
cosign attest --yes --type cyclonedx --predicate sbom.cdx.json registry.example.com/shop/api@sha256:4a1f…
  1. In CI: make the SBOM in the same job that builds the image (from the digest), upload it, and scan it. A central place like Dependency-Track keeps all SBOMs and alerts on new CVEs.

123.3

Check that it worked

sbom.cdx.json exists and lists the OS packages and the app libraries (pip/npm/jar), jq '.components | length' shows a realistic number, and Grype/Trivy read it without errors.

Commando's in deze les

123.4

Common problems

ProblemCauseFix
App libraries missing in the SBOMBuilt from a folder without lock files, or a stripped binary.Scan the final image; keep lock files; Go binaries need build info (-trimpath is fine).
unauthorized for a private registryNo registry login for Syft.docker login first (Syft reads the Docker config).
The SBOM is for the wrong imageA tag was moved.Use the digest (@sha256:…).
Different tools show different countsDifferent detectors and formats.Pick one tool chain and use it everywhere.
Nobody looks at the SBOMsFiles only, no process.Store them centrally (Dependency-Track) and scan daily.
Vulnerabilities in packages you do not useThe base image has them.Smaller base images; --only-fixed to focus.

123.5

Go further

1Why keep an SBOM for every release?

When a new CVE appears, you can find every affected image from the lists, without pulling and scanning all images again.

2Which tool makes the SBOM and which checks it for CVEs?

Syft makes it; Grype (or Trivy) scans it.

Alle commando's in dit hoofdstuk