Tutorials · DevSecOps & Cloud

How to Generate an SBOM for Your Software and Scan It With Grype

A Software Bill of Materials lists every component in your software. Customers and regulations (such as the EU Cyber Resilience Act) increasingly ask for it. Generate SBOMs with Syft and check them for vulnerabilities with Grype.

Intermediate12 min6 steps

Before you start

  • Syft and Grype (free, from Anchore; brew or install script)
  • A container image or project folder

Step by step

  1. Install the tools

    Both tools are single binaries.

    brew install syft grype
    
  2. Create an SBOM for an image

    Use a standard format such as CycloneDX or SPDX so other tools can read it.

    syft myapp:1.4.2 -o cyclonedx-json > myapp-1.4.2.cdx.json
    
  3. Create an SBOM for source code

    Point Syft at the project folder to list dependencies from lock files.

    syft dir:. -o spdx-json > myapp-src.spdx.json
    
  4. Scan the SBOM for vulnerabilities

    Grype reads the SBOM and matches components against vulnerability databases.

    grype sbom:./myapp-1.4.2.cdx.json --fail-on high
    
  5. Store SBOMs with each release

    Keep the SBOM next to the release artefact. When a new CVE is published, re-scan old SBOMs to see which releases are affected, without rebuilding.

  6. Share with customers

    Provide the SBOM on request or in your customer portal, together with your vulnerability handling policy.

Commands are generic, industry-standard examples. Exact syntax and menu names vary by model and firmware; check your device's manual on the Documentation page.

Pro tips

  • Generate the SBOM in the same CI job that builds the release, so it matches exactly.
  • Sign SBOMs and images (for example with Sigstore cosign) to prove they are authentic.