feat(yocto): the recipe inventory becomes SBOM components, CVE_STATUS and CVE patches become VEX #551

Merged
sharang merged 1 commits from feat/yocto-recipe-inventory into main 2026-10-09 16:17:49 +00:00
Owner

Yocto tier 1, part b+c+f: the recipe inventory of a layer tree, without a build.

What it does

  • Helper docker/pruefwerk_yocto_recipes.py, shipped in the agent image with oelint-parser==8.13.2 (BSD-2-Clause; regex, deprecated pinned; wrapt stays semgrep's 1.x, verified with pip check on bookworm). Each .bb is parsed with its .bbappends; prints JSON per recipe: BPN, PV (variable or name_ver.bb), first upstream SRC_URI, SRCREV, LICENSE, CVE_PRODUCT, CVE_VERSION, CVE_STATUS / CVE_STATUS_GROUPS / CVE_CHECK_IGNORE, and the SRC_URI patches with their CVE: tags. Images, package groups and -native/nativesdk-/-cross recipes are skipped. It never runs recipe code; includes outside the tree and oe.utils.read_file are refused (a recipe could otherwise pull e.g. /proc/1/environ into a stored value), and the Rust side drops implausible values. Poky meta (834 recipes) parses in about a minute.

  • Stage pipeline/yocto_inventory.rs (stage id recipe_inventory): runs the helper with env_clear, python3 -I and a 10 min timeout. If the helper fails, if some recipes cannot be parsed, or if the tree has no recipe, the stage is recorded as skipped. Components get package_manager = yocto-recipe:

    • purl pkg:github/owner/repo@ver when the source is on GitHub, else pkg:generic/<bpn>@<ver>?download_url=… (tarball) or ?vcs_url=git+…@SRCREV
    • CPE cpe:2.3:a:<vendor|*>:<CVE_PRODUCT or BPN>:<CVE_VERSION or PV>:… (new SbomEntry.cpe field, exported as the CycloneDX cpe and the SPDX cpe23Type)
    • LICENSE with &/| written as AND/OR
    • PV 1.0+git${SRCPV} becomes 1.0; git/AUTOINC with no release falls back to SRCREV (listed, but not CVE-matched) or unknown.
  • Labelling: "Yocto recipe inventory (not the image SBOM)" appears as the "Yocto-Rezept" badge with an over-reporting hint in the SBOM view, the CycloneDX property pruefwerk:component:source, the SPDX package comment, and the component's evidence line (recipe + bbappends).

  • CRA view: a target whose SBOM is the recipe inventory gets the new control state Teilweise bewertet / Partly assessed on the component controls (cra-ai-22/23/33), with the reason "recipe inventory only, not the image SBOM". The state is in the API counts (partial), the CRA bar and the compliance page (decided).

  • CVEs: NVD CPE match (new nvd_cpe::match_cves for products known only at runtime; same cache and retry) per CVE_PRODUCT, else per BPN. These components are not sent to OSV. Recipes with only file:// sources and no CVE_PRODUCT (the customer's own code) are not looked up. It uses NVD_API_KEY (sent as the apiKey header). Requests are paced to 50 per 30 s with the key and 5 per 30 s without; cached answers (6 h) cost nothing. The stage has a 10 min NVD budget; recipes with no version, a failed lookup, or outside the budget are listed under "CVE-Abgleich unvollständig".

  • VEX: vex_lifecycle::apply_scan_statements runs after the alerts are stored. It only writes where there is no statement or vex.by_scan is set, so a person's statement is never replaced. upsert_reported now withdraws every scan-made statement (before, only scan-made fixed ones), so a CVE_STATUS removed from a recipe disappears on the next scan. Mapping (from cve-check-map.conf):

    • CVE: patch / backported-patch / cpe-stable-backport / fixed-version → fixed
    • cpe-incorrect → not_affected + component_not_present
    • not-applicable-platform|config → not_affected + vulnerable_code_not_present
    • upstream-wontfix / disputed / ignored → under_investigation (CycloneDX in_triage), with "Yocto CVE_STATUS "" in : " as the note: OpenVEX status_notes, a CSAF impact threat, the CycloneDX analysis detail (decided)
    • unpatched / vulnerable-investigation → no statement

    The recipe or patch path plus the CVE_STATUS text become the impact statement, so they show up in the OpenVEX, CycloneDX VEX and CSAF exports.

  • Gate: the stage runs when the classification from #550 says Yocto, or when the plan includes RecipeInventory (Yocto targets). scan_matrix::RECIPE_INVENTORY is now None.

  • Fixture fw-yocto-layer:

    • busybox_1.35.0.bb, with CVE_STATUS not-applicable-config for CVE-2022-28391
    • a busybox_%.bbappend with a CVE_STATUS_GROUPS entry
    • a patch tagged CVE: CVE-2022-30065
    • libmodbus_3.1.6.bb, GitHub git source with SRCREV, CVE_PRODUCT = libmodbus:libmodbus
    • pump-image.bb with EXTRA_IMAGE_FEATURES ?= "debug-tweaks" (for the lint PR)

    Baseline: three yocto-recipe: components; recipe_inventory removed from the skipped stages; CVEs as a lower bound (CVE-2022-0367, -28391, -30065, -48174, checked against live NVD ranges today).

  • Docs: new "Recipe inventory" section in docs/guide/yocto.md, plus a pointer and the VEX note in sbom.md.

Tests

  • Unit (yocto_inventory): PV cleaning, commit/unknown versions, GitHub/generic purls, CPE/marker/escaping, labelling and evidence, which recipes are queried, the CVE_STATUS→OpenVEX mapping, status/patch statements, statements per alert, dropping implausible values, and the helper on the fixture (skips cleanly without python3 + oelint_parser; CI has neither, so it runs only locally or in the image).
  • cve::yocto_recipes_are_left_to_nvd_not_asked_of_osv, sbom_docs::a_yocto_recipe_says_it_is_not_the_image_sbom_in_both_formats, purl::an_encoded_value_parses_back_to_itself, updated plan/scan_matrix tests.
  • Integration vex_lifecycle::a_recipe_states_vex_each_scan_but_never_over_a_person (Mongo): statements reach OpenVEX, a person's statement is kept, and a withdrawn CVE_STATUS is cleared.

Decisions (made) and follow-ups

  • 1: NVD key and pacing are done. Follow-up: the daily CVE monitor (scheduler.rs) re-checks only OSV, so recipes are re-matched in NVD only by a scan (the same is true for embedded/CODESYS components).
  • 3: set-aside CVE_STATUS values are now under_investigation; 4: partial CRA state. Both are done, see above.
  • 2, 5, 6 stay as they are: file://-only recipes are not matched; CVE_STATUS for unmatched CVEs is not exported; fixed-version → fixed.
  • 7 (notifications and tracker issues ignore VEX) is for a separate PR.
  • Rebased onto #552: one shared oelint-parser pin (OELINT_PARSER_VERSION, with its own tool-versions entry); the fixture keeps #552's lint findings exactly (the oelint-adv fixture test passes locally with my recipes added). The baseline now lists five recipe components, including #552's pump-fw and pump-web. "Vendor code ... in the SBOM" for upstream layers is now true through the inventory, so the text is unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

Yocto tier 1, part b+c+f: the recipe inventory of a layer tree, without a build. ## What it does - **Helper** `docker/pruefwerk_yocto_recipes.py`, shipped in the agent image with `oelint-parser==8.13.2` (BSD-2-Clause; `regex`, `deprecated` pinned; wrapt stays semgrep's 1.x, verified with `pip check` on bookworm). Each `.bb` is parsed with its `.bbappend`s; prints JSON per recipe: BPN, PV (variable or `name_ver.bb`), first upstream SRC_URI, SRCREV, LICENSE, CVE_PRODUCT, CVE_VERSION, CVE_STATUS / CVE_STATUS_GROUPS / CVE_CHECK_IGNORE, and the SRC_URI patches with their `CVE:` tags. Images, package groups and `-native`/`nativesdk-`/`-cross` recipes are skipped. It never runs recipe code; includes outside the tree and `oe.utils.read_file` are refused (a recipe could otherwise pull e.g. `/proc/1/environ` into a stored value), and the Rust side drops implausible values. Poky `meta` (834 recipes) parses in about a minute. - **Stage** `pipeline/yocto_inventory.rs` (stage id `recipe_inventory`): runs the helper with `env_clear`, `python3 -I` and a 10 min timeout. If the helper fails, if some recipes cannot be parsed, or if the tree has no recipe, the stage is recorded as skipped. Components get `package_manager = yocto-recipe`: - purl `pkg:github/owner/repo@ver` when the source is on GitHub, else `pkg:generic/<bpn>@<ver>?download_url=…` (tarball) or `?vcs_url=git+…@SRCREV` - CPE `cpe:2.3:a:<vendor|*>:<CVE_PRODUCT or BPN>:<CVE_VERSION or PV>:…` (new `SbomEntry.cpe` field, exported as the CycloneDX `cpe` and the SPDX `cpe23Type`) - LICENSE with `&`/`|` written as AND/OR - PV `1.0+git${SRCPV}` becomes `1.0`; `git`/AUTOINC with no release falls back to SRCREV (listed, but not CVE-matched) or unknown. - **Labelling**: "Yocto recipe inventory (not the image SBOM)" appears as the "Yocto-Rezept" badge with an over-reporting hint in the SBOM view, the CycloneDX property `pruefwerk:component:source`, the SPDX package `comment`, and the component's evidence line (recipe + bbappends). - **CRA view**: a target whose SBOM is the recipe inventory gets the new control state **Teilweise bewertet / Partly assessed** on the component controls (cra-ai-22/23/33), with the reason "recipe inventory only, not the image SBOM". The state is in the API counts (`partial`), the CRA bar and the compliance page (decided). - **CVEs**: NVD CPE match (new `nvd_cpe::match_cves` for products known only at runtime; same cache and retry) per CVE_PRODUCT, else per BPN. These components are not sent to OSV. Recipes with only `file://` sources and no CVE_PRODUCT (the customer's own code) are not looked up. It uses `NVD_API_KEY` (sent as the `apiKey` header). Requests are paced to 50 per 30 s with the key and 5 per 30 s without; cached answers (6 h) cost nothing. The stage has a 10 min NVD budget; recipes with no version, a failed lookup, or outside the budget are listed under "CVE-Abgleich unvollständig". - **VEX**: `vex_lifecycle::apply_scan_statements` runs after the alerts are stored. It only writes where there is no statement or `vex.by_scan` is set, so a person's statement is never replaced. `upsert_reported` now withdraws every scan-made statement (before, only scan-made `fixed` ones), so a CVE_STATUS removed from a recipe disappears on the next scan. Mapping (from cve-check-map.conf): - `CVE:` patch / `backported-patch` / `cpe-stable-backport` / `fixed-version` → `fixed` - `cpe-incorrect` → `not_affected` + `component_not_present` - `not-applicable-platform|config` → `not_affected` + `vulnerable_code_not_present` - `upstream-wontfix` / `disputed` / `ignored` → `under_investigation` (CycloneDX `in_triage`), with "Yocto CVE_STATUS \"<reason>\" in <recipe>: <text>" as the note: OpenVEX `status_notes`, a CSAF `impact` threat, the CycloneDX analysis `detail` (decided) - `unpatched` / `vulnerable-investigation` → no statement The recipe or patch path plus the CVE_STATUS text become the impact statement, so they show up in the OpenVEX, CycloneDX VEX and CSAF exports. - **Gate**: the stage runs when the classification from #550 says Yocto, or when the plan includes `RecipeInventory` (Yocto targets). `scan_matrix::RECIPE_INVENTORY` is now `None`. - **Fixture** `fw-yocto-layer`: - `busybox_1.35.0.bb`, with CVE_STATUS `not-applicable-config` for CVE-2022-28391 - a `busybox_%.bbappend` with a CVE_STATUS_GROUPS entry - a patch tagged `CVE: CVE-2022-30065` - `libmodbus_3.1.6.bb`, GitHub git source with SRCREV, `CVE_PRODUCT = libmodbus:libmodbus` - `pump-image.bb` with `EXTRA_IMAGE_FEATURES ?= "debug-tweaks"` (for the lint PR) Baseline: three `yocto-recipe:` components; `recipe_inventory` removed from the skipped stages; CVEs as a lower bound (CVE-2022-0367, -28391, -30065, -48174, checked against live NVD ranges today). - **Docs**: new "Recipe inventory" section in `docs/guide/yocto.md`, plus a pointer and the VEX note in `sbom.md`. ## Tests - Unit (`yocto_inventory`): PV cleaning, commit/unknown versions, GitHub/generic purls, CPE/marker/escaping, labelling and evidence, which recipes are queried, the CVE_STATUS→OpenVEX mapping, status/patch statements, statements per alert, dropping implausible values, and the helper on the fixture (skips cleanly without `python3` + `oelint_parser`; CI has neither, so it runs only locally or in the image). - `cve::yocto_recipes_are_left_to_nvd_not_asked_of_osv`, `sbom_docs::a_yocto_recipe_says_it_is_not_the_image_sbom_in_both_formats`, `purl::an_encoded_value_parses_back_to_itself`, updated plan/scan_matrix tests. - Integration `vex_lifecycle::a_recipe_states_vex_each_scan_but_never_over_a_person` (Mongo): statements reach OpenVEX, a person's statement is kept, and a withdrawn CVE_STATUS is cleared. ## Decisions (made) and follow-ups - 1: NVD key and pacing are done. **Follow-up:** the daily CVE monitor (`scheduler.rs`) re-checks only OSV, so recipes are re-matched in NVD only by a scan (the same is true for embedded/CODESYS components). - 3: set-aside CVE_STATUS values are now `under_investigation`; 4: partial CRA state. Both are done, see above. - 2, 5, 6 stay as they are: `file://`-only recipes are not matched; CVE_STATUS for unmatched CVEs is not exported; `fixed-version` → `fixed`. - 7 (notifications and tracker issues ignore VEX) is for a separate PR. - Rebased onto #552: one shared oelint-parser pin (`OELINT_PARSER_VERSION`, with its own tool-versions entry); the fixture keeps #552's lint findings exactly (the oelint-adv fixture test passes locally with my recipes added). The baseline now lists five recipe components, including #552's pump-fw and pump-web. "Vendor code ... in the SBOM" for upstream layers is now true through the inventory, so the text is unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Author
Owner

Product decision 7, found after opening the PR: CVE notifications and tracker issues (cve_issues / issue_sync) do not read the VEX statement. A CVE that a recipe marks not_affected through CVE_STATUS therefore still raises a notification and opens or keeps a tracker issue, the same as any CVE someone set to not_affected by hand. Not changed here (out of scope). Should a not_affected/fixed statement suppress the issue? Also checked: a hostile recipe (require /etc/hostname, ${@oe.utils.read_file(...)}, file://../../etc/hostname) leaks nothing into the JSON.

Product decision 7, found after opening the PR: CVE notifications and tracker issues (`cve_issues` / `issue_sync`) do not read the VEX statement. A CVE that a recipe marks `not_affected` through CVE_STATUS therefore still raises a notification and opens or keeps a tracker issue, the same as any CVE someone set to not_affected by hand. Not changed here (out of scope). Should a not_affected/fixed statement suppress the issue? Also checked: a hostile recipe (`require /etc/hostname`, `${@oe.utils.read_file(...)}`, `file://../../etc/hostname`) leaks nothing into the JSON.
sharang force-pushed feat/yocto-recipe-inventory from 81f27ddc86 to 09863dafef 2026-10-09 15:29:52 +00:00 Compare
sharang added 1 commit 2026-10-09 16:06:46 +00:00
feat(yocto): the recipe inventory becomes SBOM components, CVE_STATUS and CVE patches become VEX
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 10m43s
13690e7408
A Yocto layer tree (classified as one, or a Yocto target) gets a recipe
inventory: an image helper parses every recipe with oelint-parser (never
runs recipe code, confined to the tree) and the recipe_inventory stage turns
the recipes into SBOM components (purl pkg:github or pkg:generic with
download_url/vcs_url, CPE from CVE_PRODUCT and CVE_VERSION, LICENSE as
SPDX), labelled "Yocto recipe inventory (not the image SBOM)" in the SBOM
view, the CycloneDX/SPDX exports and the evidence line. The components are
matched in NVD by CPE within a budget of their own, paced to the rate limit
of NVD_API_KEY. CVE_STATUS (and groups, CVE_CHECK_IGNORE) and CVE: patch
tags become scan-made VEX statements that never replace a person's:
patched ones fixed, inapplicable ones not_affected, set-aside ones
(upstream-wontfix, disputed, ignored) under_investigation with the reason as
the status note. The CRA component controls of a target whose SBOM is the
recipe inventory are partly assessed (new state). The matrix turns
recipe_inventory on; the nightly fixture gains BusyBox, libmodbus, a
CVE_STATUS, a CVE_STATUS group and a CVE: patch.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang force-pushed feat/yocto-recipe-inventory from 09863dafef to 13690e7408 2026-10-09 16:06:46 +00:00 Compare
sharang merged commit ac50880b25 into main 2026-10-09 16:17:49 +00:00
Sign in to join this conversation.