fix(sbom): firmware SBOMs list what the manifests declare (#317)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 6m28s

A firmware SBOM held a toolchain with no version and no libraries at all,
for every build system, because the analysis path could only report
libraries a build had already fetched. Zephyr and its modules, ESP-IDF
components, PlatformIO platform and lib_deps, and CMake FetchContent
packages were all missing, and the reproducible build is off in shared
deployments, so that path is the one customers get.

Firmwerk now reads those manifests (platform/firmwerk#38) and renders the
analysis-only SBOM through the same model as a sealed build, so this side
just maps its components:

    zephyr-pinned  toolchain:zephyr-sdk, zephyr v3.6.0, cmsis,
                   hal_nordic, mbedtls
    espidf         esp-idf, espressif/led_strip 2.5.3, espressif/mdns
    platformio     espressif32 6.5.0, ArduinoJson 7.0.4, PubSubClient 2.8
    freertos-cmake freertos_kernel V11.1.0
    cargo-embedded toolchain:rustc 1.82.0

A manifest that declares a range pins no version, so the row carries a
`version_requirement` instead and the dashboard shows "^1.2.0 (declared)"
rather than an empty cell. Nothing presents a range as the version CVE
matching joins on.

Also drops Syft's `file` components: it catalogued each GitHub Actions
workflow as a package named by its absolute clone path, which is the
third symptom in #317.

The firmwerk dependency is pinned by revision until that PR is released
and tagged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
Sharang ParnerkarandClaude Opus 5 committed 2026-09-22 22:07:23 +02:00
1 parent 42c7b09151
commit 6dbf58638e
16 files changed
+153 -49

No files matched your search

Generated
+42 -7
View File
@@ -104,6 +104,12 @@ dependencies = [
"rustversion",
]
[[package]]
name = "arraydeque"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236"
[[package]]
name = "askama_escape"
version = "0.13.0"
@@ -2153,20 +2159,21 @@ checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
[[package]]
name = "firmwerk-core"
version = "0.4.2"
source = "git+ssh://git@git.breakpilot.com:22222/platform/firmwerk.git?tag=v0.4.2#396dbd257ad02e867c4a875384a9bafd94f5ad8e"
version = "0.5.0"
source = "git+ssh://git@git.breakpilot.com:22222/platform/firmwerk.git?rev=e08d9e2#e08d9e2b29a383d9a7852fe5478df89cd9807306"
dependencies = [
"serde",
"tempfile",
"thiserror 1.0.69",
"toml",
"walkdir",
"yaml-rust2",
]
[[package]]
name = "firmwerk-repro"
version = "0.4.2"
source = "git+ssh://git@git.breakpilot.com:22222/platform/firmwerk.git?tag=v0.4.2#396dbd257ad02e867c4a875384a9bafd94f5ad8e"
version = "0.5.0"
source = "git+ssh://git@git.breakpilot.com:22222/platform/firmwerk.git?rev=e08d9e2#e08d9e2b29a383d9a7852fe5478df89cd9807306"
dependencies = [
"firmwerk-core",
"serde",
@@ -2180,8 +2187,8 @@ dependencies = [
[[package]]
name = "firmwerk-sbom"
version = "0.4.2"
source = "git+ssh://git@git.breakpilot.com:22222/platform/firmwerk.git?tag=v0.4.2#396dbd257ad02e867c4a875384a9bafd94f5ad8e"
version = "0.5.0"
source = "git+ssh://git@git.breakpilot.com:22222/platform/firmwerk.git?rev=e08d9e2#e08d9e2b29a383d9a7852fe5478df89cd9807306"
dependencies = [
"firmwerk-core",
"firmwerk-repro",
@@ -2580,6 +2587,24 @@ dependencies = [
"foldhash 0.2.0",
]
[[package]]
name = "hashbrown"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
dependencies = [
"foldhash 0.2.0",
]
[[package]]
name = "hashlink"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a596f1b20ed2cc5ecac41a164aaebc7258057060f06c0cf7a2ba3991ee7990fb"
dependencies = [
"hashbrown 0.17.1",
]
[[package]]
name = "headers"
version = "0.4.1"
@@ -3755,7 +3780,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.60.2",
]
[[package]]
@@ -7311,6 +7336,16 @@ dependencies = [
"lzma-sys",
]
[[package]]
name = "yaml-rust2"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57e5b818a27a4cd30884ea380857a5e56f7ec3ba24a3990a3cc0b95af3238e18"
dependencies = [
"arraydeque",
"hashlink",
]
[[package]]
name = "yoke"
version = "0.8.1"
+8 -6
View File
@@ -17,15 +17,17 @@ werkbank-exec = { path = "../werkbank-exec" }
# Native firmware build/target detection for bare-metal & RTOS artifacts.
# Same-company IP, used directly (not via CLI) so the whole firmwerk suite is
# available to the onboarding classifier. Repo: git.breakpilot.com/platform/firmwerk;
# crates are firmwerk-* from tag v0.4.2.
# crates are firmwerk-* pinned by revision until the release that carries the
# declared-dependency SBOM is tagged (platform/firmwerk#38, then tag v0.6.0).
# NOTE: CI must be able to fetch this
# private repo (see the git-auth step in .gitea/workflows/ci.yml).
firmwerk-core = { git = "ssh://git@git.breakpilot.com:22222/platform/firmwerk.git", tag = "v0.4.2" }
firmwerk-core = { git = "ssh://git@git.breakpilot.com:22222/platform/firmwerk.git", rev = "e08d9e2" }
# firmwerk-repro drives the reproducible build (NixBackend seal_and_build) that
# yields a sealed lock; `libraries_from_inputs` is the analysis-only fallback.
firmwerk-repro = { git = "ssh://git@git.breakpilot.com:22222/platform/firmwerk.git", tag = "v0.4.2" }
# firmwerk-sbom renders the bill of materials from a sealed lock (+ binary SCA).
firmwerk-sbom = { git = "ssh://git@git.breakpilot.com:22222/platform/firmwerk.git", tag = "v0.4.2" }
# yields a sealed lock.
firmwerk-repro = { git = "ssh://git@git.breakpilot.com:22222/platform/firmwerk.git", rev = "e08d9e2" }
# firmwerk-sbom renders the bill of materials from a sealed lock or, without a
# build, from the analysed plan (+ binary SCA).
firmwerk-sbom = { git = "ssh://git@git.breakpilot.com:22222/platform/firmwerk.git", rev = "e08d9e2" }
serde = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true }
+44 -24
View File
@@ -169,34 +169,18 @@ fn component_to_entry(c: &firmwerk_sbom::Component, repo_id: &str) -> SbomEntry
c.version.clone().unwrap_or_default(),
manager.to_string(),
);
entry.purl = c.source.clone();
entry.purl = c.purl.clone().or_else(|| c.source.clone());
// A manifest that declares a range pins no version; carrying the requirement keeps the row
// honest instead of showing an empty version with no reason.
entry.version_requirement = c.declared.as_ref().and_then(|d| d.requirement.clone());
entry
}
/// Analysis-only components from the build plan: the cross-toolchain plus the
/// resolvable fetched libraries, without a build.
/// Analysis-only components from the build plan, without a build: the cross-toolchain, the
/// dependencies the project's manifests declare, and the libraries detection identified in the
/// source. Firmwerk renders it into the same model as a sealed build, so both read the same way.
fn analysis_entries(bp: &firmwerk_core::BuildPlan, repo_id: &str) -> Vec<SbomEntry> {
let mut entries = Vec::new();
if let Some(id) = bp.toolchain.id.clone() {
let version = bp.toolchain.version.clone().unwrap_or_default();
entries.push(SbomEntry::new(
repo_id.to_string(),
id,
version,
"toolchain".to_string(),
));
}
for lib in firmwerk_repro::lock::libraries_from_inputs(&bp.inputs) {
let mut entry = SbomEntry::new(
repo_id.to_string(),
lib.name,
lib.revision,
"library".to_string(),
);
entry.purl = lib.source;
entries.push(entry);
}
entries
sbom_to_entries(&firmwerk_sbom::Sbom::from_plan(bp, repo_id), repo_id)
}
#[cfg(test)]
@@ -221,6 +205,42 @@ mod tests {
);
}
#[tokio::test]
async fn a_zephyr_app_lists_what_its_west_manifest_declares() {
let entries = firmware_sbom_entries(&fixture("zephyr-pinned"), "t", ExecPolicy::default())
.await
.expect("a west manifest forms a build plan");
let find = |name: &str| entries.iter().find(|e| e.name == name);
let zephyr = find("zephyr").expect("zephyr itself is a component");
assert_eq!(zephyr.version, "v3.6.0");
assert_eq!(
zephyr.purl.as_deref(),
Some("pkg:github/zephyrproject-rtos/zephyr@v3.6.0")
);
// An imported module is named even though its revision lives in zephyr's own manifest.
assert!(find("cmsis").is_some(), "{entries:?}");
}
#[tokio::test]
async fn a_declared_range_is_a_requirement_not_a_version() {
let entries = firmware_sbom_entries(&fixture("espidf"), "t", ExecPolicy::default())
.await
.expect("an esp-idf project forms a build plan");
let mdns = entries
.iter()
.find(|e| e.name == "espressif/mdns")
.expect("a declared component");
assert_eq!(mdns.version, "");
assert_eq!(mdns.version_requirement.as_deref(), Some("^1.2.0"));
// A pinned one carries its version.
let led = entries
.iter()
.find(|e| e.name == "espressif/led_strip")
.expect("a pinned component");
assert_eq!(led.version, "2.5.3");
assert_eq!(led.version_requirement, None);
}
#[tokio::test]
async fn a_make_project_yields_its_toolchain() {
let entries = firmware_sbom_entries(&fixture("make"), "t", ExecPolicy::default())
+4 -1
View File
@@ -39,6 +39,10 @@ pub(super) async fn run_syft(repo_path: &Path, repo_id: &str) -> Result<Vec<Sbom
.components
.unwrap_or_default()
.into_iter()
// Syft catalogues the files it read as `file` components: a GitHub Actions workflow, say,
// shows up under its absolute clone path as a package of its own. Those are not
// dependencies (the actions it uses are catalogued separately, with purls).
.filter(|c| c.component_type.as_deref() != Some("file"))
.map(|c| {
let package_manager = c
.purl
@@ -71,7 +75,6 @@ struct CdxComponent {
name: String,
version: Option<String>,
#[serde(rename = "type")]
#[allow(dead_code)]
component_type: Option<String>,
purl: Option<String>,
licenses: Option<Vec<CdxLicenseWrapper>>,
+6
View File
@@ -17,6 +17,11 @@ pub struct SbomEntry {
pub name: String,
pub version: String,
pub package_manager: String,
/// The version requirement a manifest declares where it pins no exact version (`^1.2.0`,
/// `>=5.1.2`, a branch). Kept apart from `version`, which CVE matching joins on: a range must
/// never be read as the version in use.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub version_requirement: Option<String>,
pub license: Option<String>,
pub purl: Option<String>,
pub known_vulnerabilities: Vec<VulnRef>,
@@ -35,6 +40,7 @@ impl SbomEntry {
name,
version,
package_manager,
version_requirement: None,
license: None,
purl: None,
known_vulnerabilities: Vec::new(),
@@ -19,6 +19,10 @@ pub struct SbomEntryData {
pub name: String,
pub version: String,
pub package_manager: String,
/// What a manifest asks for where it pins no version (`^1.2.0`, a branch), shown instead of
/// an empty version cell.
#[serde(default)]
pub version_requirement: Option<String>,
pub license: Option<String>,
pub purl: Option<String>,
#[serde(default)]
+11 -1
View File
@@ -273,7 +273,7 @@ pub fn SbomPage() -> Element {
}
td {
style: "font-family: var(--font-mono, monospace); font-size: 13px;",
"{entry.version}"
"{version_label(&entry)}"
}
td { "{entry.package_manager}" }
td {
@@ -650,6 +650,16 @@ fn pm_display_name(pm: &str) -> &str {
}
}
/// What to show in the version column. A dependency a manifest declares as a range (or a branch)
/// has no version to pin a CVE to, so the requirement is shown as such rather than an empty cell.
fn version_label(entry: &SbomEntryData) -> String {
match (entry.version.as_str(), entry.version_requirement.as_deref()) {
("", Some(requirement)) => format!("{requirement} (declared)"),
("", None) => "-".to_string(),
(version, _) => version.to_string(),
}
}
fn license_css_class(license: Option<&str>) -> &'static str {
match license {
Some(l) => {
@@ -12,10 +12,11 @@
"github:actions/upload-pages-artifact@v5.0.0",
"github:zephyrproject-rtos/action-dco@v1.0.0",
"github:zephyrproject-rtos/action-zephyr-setup@v1.0.15",
"toolchain:zephyr-sdk@",
"unknown:/tmp/compliance-scanner/repos/dev/Demo___Firmware_RTOS___Zephyr_example-application/.github/workflows/build.yml@unknown",
"unknown:/tmp/compliance-scanner/repos/dev/Demo___Firmware_RTOS___Zephyr_example-application/.github/workflows/dco.yml@unknown",
"unknown:/tmp/compliance-scanner/repos/dev/Demo___Firmware_RTOS___Zephyr_example-application/.github/workflows/docs.yml@unknown"
"library:cmsis_6@",
"library:hal_nordic@",
"library:hal_stm32@",
"library:zephyr@",
"toolchain:zephyr-sdk@"
],
"findings": [],
"cves": [],
@@ -4,7 +4,7 @@
"code_scan"
],
"sbom": [
"toolchain:rustc@"
"toolchain:rustc@1.82.0"
],
"findings": [],
"cves": [],
@@ -4,6 +4,9 @@
"code_scan"
],
"sbom": [
"library:esp-idf@",
"library:espressif/led_strip@2.5.3",
"library:espressif/mdns@",
"toolchain:esp-idf-toolchain@"
],
"findings": [],
@@ -4,6 +4,7 @@
"code_scan"
],
"sbom": [
"library:freertos_kernel@V11.1.0",
"toolchain:arm-none-eabi-gcc@"
],
"findings": [],
@@ -4,6 +4,9 @@
"code_scan"
],
"sbom": [
"library:ARM CMSIS Core@",
"library:FreeRTOS@",
"library:STM32 HAL/CMSIS@",
"toolchain:arm-none-eabi-gcc@"
],
"findings": [],
@@ -1,10 +1,13 @@
{
"scan_status": "completed",
"skipped_stages": [
"code_scan",
"firmware_sbom"
"code_scan"
],
"sbom": [
"library:bblanchon/ArduinoJson@7.0.4",
"library:espressif32@6.5.0",
"library:knolleary/PubSubClient@2.8"
],
"sbom": [],
"findings": [],
"cves": [],
"registry_rules": []
@@ -4,6 +4,10 @@
"code_scan"
],
"sbom": [
"library:cmsis_6@",
"library:hal_nordic@",
"library:hal_stm32@",
"library:zephyr@",
"toolchain:zephyr-sdk@"
],
"findings": [],
@@ -4,6 +4,10 @@
"code_scan"
],
"sbom": [
"library:cmsis@",
"library:hal_nordic@",
"library:mbedtls@",
"library:zephyr@v3.6.0",
"toolchain:zephyr-sdk@"
],
"findings": [],
+7 -2
View File
@@ -3,8 +3,8 @@
Each directory is uploaded as a source archive (the harness zips it) and
exercises one Firmwerk build-system provider. Most are copied from Firmwerk's
own provider tests (`crates/firmwerk-core/tests/fixtures`, Firmwerk v0.4.2),
extended with the manifests a real project carries (marked "+"), so the
baselines show when those start to reach the SBOM (#317):
extended with the manifests a real project carries (marked "+"), which the
SBOM reads as declared dependencies (#317):
| Directory | Firmwerk fixture | Provider |
|---|---|---|
@@ -20,3 +20,8 @@ baselines show when those start to reach the SBOM (#317):
| `yocto-layer` | (ours) | none: Yocto is not analysed yet, so the scan must record it |
When Firmwerk's detection changes on purpose, refresh the copy and re-bless.
The baselines record what each manifest declares (`library:zephyr@v3.6.0`,
`library:espressif/led_strip@2.5.3`) and, where a manifest gives a range
instead of a version, the row carries the requirement rather than a version a
CVE could be matched against.