feat(yocto): a target's build output joins the scan (#150) #853

Merged
sharang merged 2 commits from feat/yocto-build-output into main 2026-11-04 22:42:49 +00:00
Owner

#150, PR 2a: the agent side. The reader came in #852; PR 2b adds the wizard and docs. Tracker #167.

What

  • New artifact kind build_output (ArtifactKind::BuildOutput): a Yocto image's SPDX archive, <image>.spdx.tar.zst.
    • Uploaded through the existing POST /api/v1/targets/{id}/artifacts with kind=build_output.
    • Stored as uploaded: no extraction, because the reader opens it itself.
    • It counts as an upload for change detection, so a new archive means a new scan.
    • The classifier takes it as Yocto evidence (0.7).
  • Scan: run_target hands the ingested paths to scan_tree through RepoView::build_outputs. read_build_outputs reads each archive; one it cannot read gets a run note build_spdx (ArtifactNotIngested), and the scan carries on.
  • pipeline::yocto_build::Built joins the build with the recipe inventory by recipe name. The layer's PV and the built version differ (busybox_1.35.0.bb vs 1.36.1 built; linux-yocto 6.6 vs 6.6.151+git), so a name+version join would double-count.
    • merge:
      • For a recipe in both, the build's version, CPE, licence and InImageBasis::Built win, and the evidence of both is kept.
      • An image the SPDX covers is authoritative. A recipe declared in it but not installed loses the marking. Declarations for other images stay, as evidence.
      • Built-only recipes are added, and non-recipe components are untouched.
    • nvd_queries: the built version and CPE replace the inventory's query for that recipe. Every built recipe with a CPE is asked about within the existing NVD_BUDGET, and recipes without a release version are listed as unchecked.
    • statements: VEX fixed for the CVEs the build's patches fixed (create-spdx CVEs fixed). Otherwise the recipe's CVE_STATUS and CVE: patches apply, joined by name. Alerts on non-built components go through vex_statements as before.
  • Unresolved packages (listed in the image without a document) get an informational note via the new SkipCode::BuildPackagesUnresolved, with DE/EN texts and a stage label.
  • Dashboard: the SBOM page's "im Image" tooltip now depends on the basis: declared in the recipes, or installed by the build.
  • yocto_inventory::release_of and scan_statement are now pub(crate).

Notes

  • Kernel volume: a real image includes linux-yocto with CPE linux_kernel. In the ferrite sample its SPDX lists 14,182 fixed CVEs, and cve-check counts 622 unpatched. So NVD returns thousands of kernel CVEs, almost all settled fixed by this PR. This is correct, but it is a lot of alerts per scan. PR 3 (cve-check JSON) adds Yocto's own verdicts on top.
  • Not covered here: a target with build outputs but no code artifact (no layer tree, no archive). run_target's no-code-artifact branch does not run the scan, and that is likely the #167 customer's shape. That is a follow-up.
  • Nightly: the nightly runs the agent image from main, so it cannot exercise this branch. After the merge, a nightly target (the existing layer fixture plus the trimmed archive from #852) gets its baseline blessed against the deployed agent, in a small follow-up PR.

Tests

  • Unit tests (yocto_build.rs, against the #852 fixture):
    • the name join with differing versions;
    • a declared marking dropped for the covered image and kept for another;
    • built-only recipes added and other managers untouched;
    • queries with the built version and the vendor CPE, with no query for a package group;
    • fixed statements;
    • CPE parsing.
  • Plus the build_output Display test.
  • CI only.

🤖 Generated with Claude Code

#150, PR 2a: the agent side. The reader came in #852; PR 2b adds the wizard and docs. Tracker #167. ## What - **New artifact kind** `build_output` (`ArtifactKind::BuildOutput`): a Yocto image's SPDX archive, `<image>.spdx.tar.zst`. - Uploaded through the existing `POST /api/v1/targets/{id}/artifacts` with `kind=build_output`. - Stored as uploaded: no extraction, because the reader opens it itself. - It counts as an upload for change detection, so a new archive means a new scan. - The classifier takes it as Yocto evidence (0.7). - **Scan:** `run_target` hands the ingested paths to `scan_tree` through `RepoView::build_outputs`. `read_build_outputs` reads each archive; one it cannot read gets a run note `build_spdx` (`ArtifactNotIngested`), and the scan carries on. - **`pipeline::yocto_build::Built`** joins the build with the recipe inventory by recipe name. The layer's PV and the built version differ (`busybox_1.35.0.bb` vs 1.36.1 built; `linux-yocto 6.6` vs `6.6.151+git`), so a name+version join would double-count. - **merge**: - For a recipe in both, the build's version, CPE, licence and `InImageBasis::Built` win, and the evidence of both is kept. - An image the SPDX covers is authoritative. A recipe declared in it but not installed loses the marking. Declarations for other images stay, as evidence. - Built-only recipes are added, and non-recipe components are untouched. - **nvd_queries**: the built version and CPE replace the inventory's query for that recipe. Every built recipe with a CPE is asked about within the existing `NVD_BUDGET`, and recipes without a release version are listed as unchecked. - **statements**: VEX `fixed` for the CVEs the build's patches fixed (create-spdx `CVEs fixed`). Otherwise the recipe's `CVE_STATUS` and `CVE:` patches apply, joined by name. Alerts on non-built components go through `vex_statements` as before. - **Unresolved packages** (listed in the image without a document) get an informational note via the new `SkipCode::BuildPackagesUnresolved`, with DE/EN texts and a stage label. - **Dashboard**: the SBOM page's "im Image" tooltip now depends on the basis: declared in the recipes, or installed by the build. - `yocto_inventory::release_of` and `scan_statement` are now `pub(crate)`. ## Notes - **Kernel volume:** a real image includes `linux-yocto` with CPE `linux_kernel`. In the ferrite sample its SPDX lists 14,182 fixed CVEs, and cve-check counts 622 unpatched. So NVD returns thousands of kernel CVEs, almost all settled `fixed` by this PR. This is correct, but it is a lot of alerts per scan. PR 3 (cve-check JSON) adds Yocto's own verdicts on top. - **Not covered here:** a target with build outputs but no code artifact (no layer tree, no archive). `run_target`'s no-code-artifact branch does not run the scan, and that is likely the #167 customer's shape. That is a follow-up. - **Nightly:** the nightly runs the agent image from `main`, so it cannot exercise this branch. After the merge, a nightly target (the existing layer fixture plus the trimmed archive from #852) gets its baseline blessed against the deployed agent, in a small follow-up PR. ## Tests - Unit tests (`yocto_build.rs`, against the #852 fixture): - the name join with differing versions; - a declared marking dropped for the covered image and kept for another; - built-only recipes added and other managers untouched; - queries with the built version and the vendor CPE, with no query for a package group; - `fixed` statements; - CPE parsing. - Plus the `build_output` Display test. - CI only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-04 22:18:39 +00:00
feat(yocto): a target's build output joins the scan (#150)
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 / Agent integration (pull_request) Successful in 3m32s
CI / Check (pull_request) Failing after 6m13s
eb7d7423ad
A target takes a new artifact kind, build_output: a Yocto image's SPDX
archive (<image>.spdx.tar.zst), read with pipeline::yocto_spdx (#852).
The scan joins what the build installed with the recipe inventory of
the layer tree (pipeline::yocto_build):

- by recipe name, since the tree's PV and the built version differ
  (busybox 1.35.0 in the layer, 1.36.1 built): the build's version, CPE,
  licence and InImageBasis::Built win, both evidence lines stay;
- an image the SPDX covers is authoritative: a recipe declared in it but
  not installed loses that marking; declarations for other images stay;
- recipes only the build lists are added;
- NVD is asked with the built version and CPE, one query per recipe;
- a CVE the build's patches fixed (create-spdx "CVEs fixed") is stated
  fixed; otherwise the recipe's CVE_STATUS applies, joined by name.

An archive that cannot be read, and packages listed without their
documents, are noted on the run (build_spdx; new informational
SkipCode::BuildPackagesUnresolved). The classifier takes an image SPDX
archive as Yocto evidence. The SBOM page's in-image tooltip now says
how the marking is known (declared in the recipes, or installed by the
build).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang added 1 commit 2026-11-04 22:25:57 +00:00
fix: build_output_paths before the test module (clippy)
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 / Agent integration (pull_request) Successful in 3m54s
CI / Check (pull_request) Successful in 16m34s
1f0d9c17fd
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit e637964c02 into main 2026-11-04 22:42:49 +00:00
Sign in to join this conversation.