sbom-model
format-agnostic data model for software bills of materials.
this crate provides the core types used across the sbom-diff workspace. it defines a unified representation that abstracts over specific formats like cyclonedx and spdx.
usage
use ;
// create a component
let mut component = new;
component.licenses.insert;
component.licenses.insert;
// create an sbom and add the component
let mut sbom = default;
sbom.components.insert;
// normalize for deterministic comparison
sbom.normalize;
component identification
components are identified by ComponentId, which prefers package urls (purls) when available:
use ComponentId;
// with a purl (preferred)
let id = new;
assert_eq!;
// without a purl: falls back to deterministic hash
let id = new;
assert!;
query api
the Sbom struct provides methods to query the dependency graph:
use Sbom;
normalization
sbom.normalize() prepares an sbom for deterministic comparison:
- sorts components by id
- lowercases hash algorithms and values
- strips volatile metadata (timestamps, tool versions)
related crates
sbom-model-cyclonedx- parse cyclonedx json into this modelsbom-model-spdx- parse spdx json into this modelsbom-diff- diff engine using this model