fix(vex): keep the alert's purl for components that left the SBOM #532

Merged
sharang merged 1 commits from fix/a4-alert-purl into main 2026-10-08 21:45:38 +00:00
Owner

What was wrong

After a component was updated (stage: log4j-core 2.14.1 -> 2.17.1), the alerts for the old version were resolved (fixed by scan). The exports then named the component pkg:generic/log4j-core@2.14.1 instead of pkg:maven/org.apache.logging.log4j/log4j-core@2.14.1: the exporters looked the purl up in the current SBOM, which no longer has 2.14.1, and fell back to a generic purl. Consumers could not match the fixed statements to their SBOM.

What changed

  • CveAlert gets purl: Option<String> (serde default, skipped when None): the purl of the SBOM component the alert is about.
  • Set where alerts are created: OSV (cve.rs), NVD/CPE matching (record_nvd, used by the CODESYS runtime and embedded-library paths), CSAF matching (csaf_match.rs, also filled on a merged OSV/NVD alert of the same package and version). The OSV path now uses the alert's purl for fixed_for instead of a separate name/version map.
  • Backfill on rescan: vex_lifecycle::upsert_reported $sets the alert, so a known purl is written and a missing one is never written as None; the stored purl is only dropped if the alert now names a different package/version. The hourly CVE monitor (scheduler.rs, $setOnInsert) sets the purl on an existing alert of the same package/version that has none.
  • Exports: one helper, vex_docs::component_id, already served OpenVEX, CycloneDX VEX, the CSAF VEX draft and the evidence pack (which uses the same builders). Its order is now: alert.purl, then the SBOM lookup, then pkg:generic/<name>@<version>.
  • Not changed, checked: the ENISA drafts name components only as name version text (no purl); the CycloneDX SBOM's vulnerability affects refs come from the SBOM entries themselves, not from alerts.
  • Docs: docs/guide/sbom.md (VEX section), docs/guide/vex.md / vex-en.md (CSAF draft).

Alerts resolved before this deploy cannot be backfilled (their component is no longer in the SBOM, so no scan reports them again) and still show pkg:generic/.... Alerts that are still open get their purl on the next scan or CVE-monitor run, and keep it when they are resolved later.

Tests

  • compliance-core/tests/vex_schemas.rs::a_fixed_component_that_left_the_sbom_keeps_its_stored_purl: resolved log4j 2.14.1 alert with stored maven purl, SBOM now has 2.17.1 -> OpenVEX subcomponent, CycloneDX affects.ref and CSAF product_identification_helper.purl are the maven purl; an old alert without purl still gets pkg:generic/zlib@1.2.11; all three documents pass their schemas.
  • compliance-agent/tests/vex_lifecycle.rs (against a local Mongo 7): stored alert without purl gets it on the next upsert, keeps it on an upsert without purl, drops it when the alert moves to another version.
  • Unit: cve::tests::an_nvd_alert_keeps_the_purl_of_its_component, OSV fake-server test asserts the purl, csaf_match tests assert the purl on new and merged alerts.
  • cargo fmt --all --check, clippy -D warnings for compliance-core, compliance-agent, compliance-dashboard (server and web).
  • Not run locally: the full suite (CI), the scheduler monitor path (no test harness for it).

Stage re-test

  1. Run a scan of the log4j test target (or any target with an open CVE alert) so the open alerts get their purl.
  2. Update the component (e.g. log4j-core 2.14.1 -> 2.17.1) and scan again; under Schwachstellen und VEX the old alerts show Behoben.
  3. OpenVEX herunterladen, CycloneDX VEX herunterladen and CSAF-Entwurf herunterladen: the fixed statements name pkg:maven/org.apache.logging.log4j/log4j-core@2.14.1, not pkg:generic/....
  4. Download the Nachweispaket and check vex.openvex.json / csaf-vex.json the same way.
  5. Alerts that were already resolved before the deploy still show pkg:generic/... (expected, see above).

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

## What was wrong After a component was updated (stage: log4j-core 2.14.1 -> 2.17.1), the alerts for the old version were resolved (`fixed` by scan). The exports then named the component `pkg:generic/log4j-core@2.14.1` instead of `pkg:maven/org.apache.logging.log4j/log4j-core@2.14.1`: the exporters looked the purl up in the *current* SBOM, which no longer has 2.14.1, and fell back to a generic purl. Consumers could not match the `fixed` statements to their SBOM. ## What changed - `CveAlert` gets `purl: Option<String>` (serde default, skipped when `None`): the purl of the SBOM component the alert is about. - Set where alerts are created: OSV (`cve.rs`), NVD/CPE matching (`record_nvd`, used by the CODESYS runtime and embedded-library paths), CSAF matching (`csaf_match.rs`, also filled on a merged OSV/NVD alert of the same package and version). The OSV path now uses the alert's purl for `fixed_for` instead of a separate name/version map. - Backfill on rescan: `vex_lifecycle::upsert_reported` `$set`s the alert, so a known purl is written and a missing one is never written as `None`; the stored purl is only dropped if the alert now names a different package/version. The hourly CVE monitor (`scheduler.rs`, `$setOnInsert`) sets the purl on an existing alert of the same package/version that has none. - Exports: one helper, `vex_docs::component_id`, already served OpenVEX, CycloneDX VEX, the CSAF VEX draft and the evidence pack (which uses the same builders). Its order is now: `alert.purl`, then the SBOM lookup, then `pkg:generic/<name>@<version>`. - Not changed, checked: the ENISA drafts name components only as `name version` text (no purl); the CycloneDX SBOM's vulnerability `affects` refs come from the SBOM entries themselves, not from alerts. - Docs: `docs/guide/sbom.md` (VEX section), `docs/guide/vex.md` / `vex-en.md` (CSAF draft). **Alerts resolved before this deploy cannot be backfilled** (their component is no longer in the SBOM, so no scan reports them again) and still show `pkg:generic/...`. Alerts that are still open get their purl on the next scan or CVE-monitor run, and keep it when they are resolved later. ## Tests - `compliance-core/tests/vex_schemas.rs::a_fixed_component_that_left_the_sbom_keeps_its_stored_purl`: resolved log4j 2.14.1 alert with stored maven purl, SBOM now has 2.17.1 -> OpenVEX subcomponent, CycloneDX `affects.ref` and CSAF `product_identification_helper.purl` are the maven purl; an old alert without purl still gets `pkg:generic/zlib@1.2.11`; all three documents pass their schemas. - `compliance-agent/tests/vex_lifecycle.rs` (against a local Mongo 7): stored alert without purl gets it on the next upsert, keeps it on an upsert without purl, drops it when the alert moves to another version. - Unit: `cve::tests::an_nvd_alert_keeps_the_purl_of_its_component`, OSV fake-server test asserts the purl, `csaf_match` tests assert the purl on new and merged alerts. - `cargo fmt --all --check`, clippy `-D warnings` for compliance-core, compliance-agent, compliance-dashboard (server and web). - Not run locally: the full suite (CI), the scheduler monitor path (no test harness for it). ## Stage re-test 1. Run a scan of the log4j test target (or any target with an open CVE alert) so the open alerts get their purl. 2. Update the component (e.g. log4j-core 2.14.1 -> 2.17.1) and scan again; under **Schwachstellen und VEX** the old alerts show **Behoben**. 3. **OpenVEX herunterladen**, **CycloneDX VEX herunterladen** and **CSAF-Entwurf herunterladen**: the fixed statements name `pkg:maven/org.apache.logging.log4j/log4j-core@2.14.1`, not `pkg:generic/...`. 4. Download the **Nachweispaket** and check `vex.openvex.json` / `csaf-vex.json` the same way. 5. Alerts that were already resolved before the deploy still show `pkg:generic/...` (expected, see above). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-10-08 21:22:12 +00:00
fix(vex): keep the alert's purl for components that left the SBOM
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 11m16s
3a07768024
A resolved CVE alert (its component updated past the fix) was exported
as pkg:generic/<name>@<version> in OpenVEX, CycloneDX VEX, the CSAF VEX
draft and the evidence pack, because the exporters looked the purl up in
the current SBOM. CveAlert now stores the purl of its component (OSV,
NVD/CPE incl. CODESYS and embedded, CSAF matching), a rescan backfills it
on stored alerts (scan upsert and the hourly CVE monitor), and the
exporters use it before the SBOM lookup and the generic fallback.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang merged commit 1f02a89226 into main 2026-10-08 21:45:38 +00:00
Sign in to join this conversation.