Overview
This primer is intended to help developers integrate Software Bill of Materials (SBOM) into their project(s). If you don't know what SBOMs are and why you would want to add them to your project, then this article is for you.
What is an SBOM?
An SBOM is a inventory of the software components and their relationships that comprise a software product. The primary purpose of an SBOM to provide transparency, and traceability for a software supply chain. It allows one to more easily understand the risk profile of a project by more easily identifying its sub-components. It does this through the creation of a manifest that tracks the dependencies used within a project release.
Why SBOM?
The manifest itself is a standardized machine-readable format that works with many different build systems. Each dependency will include metadata such as: the type of dependency, its name / version and other important identifying such as the originating URL and the cryptographic hash(s) of the dependency itself.
The manifests can then be published alongside the release artifacts. It should be refreshed as often as the build and dependencies are updated. Many package ecosystems already support publishing SBOMs so be sure to check your target build systems documentation.
Choosing an SBOM Format
There are two primary SBOM formats: CycloneDX and SPDX. The decision whether to use one or the other typically depended on what type of risk needed to be mitigated. The gap between the formats is closing though as interoperability also continues to improve.
- CycloneDX is an OWASP standard best characterized as a compact format that is primarily focused on cyber-security. It is a widely supported format that is intended to be extensible through other *BOM formats such as the HBOM (hardware) and CBOM (cryptographic). Dependency-Track is arguably the best open source analysis dashboard available making it a preferred tool by many.
- SPDX is an OpenSSF (under the Linux Foundation) and ISO standard that has an ever expanding list of capabilities and very robust ecosystem. SPDX was more focused on licensing risk at one point, but starting with version 2.0 the ability to track Common Vulnerabilities and Exposures (CVE) was added to it.
I will be covering CycloneDX here but both are comprehensive formats.
Generating SBOMs
The majority of tools for SBOM management are CLI-based with a few that can integrate into an analysis dashboard. This provides developers with a number of tools that are great for integration within CI/CD pipelines. It also means that some tools provide more capability than others. There are multiple tools that have a corresponding dashboard but here I'll cover syft - which is part of the Anchore ecosystem of tooling.
Note
trivyis another good alternative, but you should take care not to mix ecosystems.
First we'll install syft. I'm using MacOS but you find other supported architectures at https://github.com/anchore/syft/releases
brew install syft
We'll start with a cargo example for rust:
syft Cargo.toml \
--output cyclonedx-json=example.cdx.json
Many SBOM tools attempt support for containers as a first-class citizen of sorts. To do the tools must support many package formats that may be installed within various containers. This is what separates syft as "A Universal SBOM Generator" versus some of the other tools. It however does not support every packaging format - such as zig or goose.
# Generate SBOM in JSON for a container
syft fedora:latest \
--output cyclonedx-json=fedora-latest.json
If you want something more tailored for your build system, and don't really need either the dashboard or container support, you could just use one of the many CycloneDX build plugins.
Here is an example integrating CycloneDX plugin into cargo for rust:
# Install CycloneDX cargo plugin
cargo install cargo-cyclonedx
# Generate CycloneDX SBOM in JSON
cargo cyclonedx \
--format json \
--all-features \
--include-dev-deps
Summary
In this first article of four we covered the basic steps to integrate SBOM into your builds. However, the following articles will help use SBOMs more effectively including: using attestations to sign and verify trustworthiness, Vulnerability Exploitability eXchange (VEX) to filter the noise, and consolidating multiple SBOMs into a unified view.
Top comments (0)