fix(firmware): produce the firmware SBOM when detection finds firmware (#341)
This commit was merged in pull request #341.
This commit is contained in:
1 parent
0e0dfadf56
commit
dae80043e6
5 files changed
+39
-5
No files matched your search
@@ -19,12 +19,12 @@ use compliance_core::ExecPolicy;
|
||||
use firmwerk_repro::ReproBackend;
|
||||
use firmwerk_sbom::ComponentKind;
|
||||
|
||||
/// Whether firmware SBOM applies to this target family.
|
||||
/// The `package_manager` values firmware SBOM entries use. The firmware step
|
||||
/// replaces exactly these, and the SBOM stage leaves them alone, so neither
|
||||
/// wipes the other's entries.
|
||||
pub const FIRMWARE_MANAGERS: [&str; 3] = ["firmware", "library", "toolchain"];
|
||||
|
||||
/// Whether firmware SBOM applies to this target family.
|
||||
pub fn is_firmware_target(target_type: TargetType) -> bool {
|
||||
matches!(
|
||||
target_type,
|
||||
|
||||
@@ -1134,9 +1134,8 @@ impl PipelineOrchestrator {
|
||||
|
||||
/// Ingest the target's artifacts, classify (Firmwerk for firmware/RTOS/Yocto,
|
||||
/// heuristics otherwise), and store the detected classification on the target.
|
||||
/// Best-effort — never fails the scan.
|
||||
/// Ingest, classify and store the detected type. Returns where each artifact
|
||||
/// was ingested (artifact id -> working path), so the caller scans the tree
|
||||
/// Best-effort — never fails the scan. Returns where each artifact was
|
||||
/// ingested (artifact id -> working path), so the caller scans the tree
|
||||
/// ingest already unpacked instead of unpacking it twice.
|
||||
async fn classify_and_store(
|
||||
&self,
|
||||
@@ -1157,6 +1156,7 @@ impl PipelineOrchestrator {
|
||||
}
|
||||
};
|
||||
let working_paths = ingest_set.working_paths();
|
||||
let mut detected_firmware = false;
|
||||
match crate::classify::classify_target(
|
||||
target,
|
||||
&working_paths,
|
||||
@@ -1170,6 +1170,8 @@ impl PipelineOrchestrator {
|
||||
suggested = %classification.suggested,
|
||||
"Unified pipeline: classified target"
|
||||
);
|
||||
detected_firmware =
|
||||
crate::pipeline::firmware_sbom::is_firmware_target(classification.suggested);
|
||||
if let (Some(oid), Ok(bson)) = (target.id, mongodb::bson::to_bson(&classification))
|
||||
{
|
||||
let _ = self
|
||||
@@ -1192,7 +1194,11 @@ impl PipelineOrchestrator {
|
||||
// analysis over the already-ingested source — no build, no binary
|
||||
// upload. When no build plan forms (e.g. a Yocto layer), the run says
|
||||
// so rather than completing as if the firmware had no components.
|
||||
if crate::pipeline::firmware_sbom::is_firmware_target(target.target_type) {
|
||||
// What the code is decides, not only the type picked at onboarding: an
|
||||
// STM32 project onboarded as "backend service" still gets its SBOM.
|
||||
if detected_firmware
|
||||
|| crate::pipeline::firmware_sbom::is_firmware_target(target.target_type)
|
||||
{
|
||||
if let Some(code) = target.code_artifact() {
|
||||
if let Some(path) = working_paths.get(&code.id) {
|
||||
let entries = match crate::pipeline::firmware_sbom::firmware_sbom_entries(
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [],
|
||||
"sbom": [
|
||||
"toolchain:arm-none-eabi-gcc@"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -20,6 +20,9 @@ SBOM reads as declared dependencies (#317):
|
||||
| `c-sensor-node` | (ours) | Make; C/C++ SAST (#334): planted flaws in `Core/`, a vendored HAL in `Drivers/` that must not be reported |
|
||||
| `yocto-layer` | (ours) | none: Yocto is not analysed yet, so the scan must record it |
|
||||
|
||||
`make` is also onboarded as a backend service (`fw-make-onboarded-as-service`):
|
||||
the firmware SBOM follows detection, not the type picked in the wizard.
|
||||
|
||||
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`,
|
||||
|
||||
@@ -106,6 +106,21 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fw-make-onboarded-as-service",
|
||||
"name": "Firmware · Make, onboarded as a backend service",
|
||||
"target_type": "backend_service",
|
||||
"description": "The Make firmware project with the wrong type picked at onboarding: detection must still produce the firmware SBOM.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload": "fixtures/nightly/firmware/make"
|
||||
}
|
||||
],
|
||||
"expect": {
|
||||
"min_sbom_components": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "fw-cmake",
|
||||
"name": "Firmware · CMake",
|
||||
|
||||
Reference in new issue
Block a user