fix(vex): alerts stored before purls get their component's purl #537

Merged
sharang merged 1 commits from fix/a4-purl-migration into main 2026-10-08 22:55:23 +00:00
Owner

What was wrong (A4 re-test on stage): #532 stores the purl when an alert is created, and refreshes it when a scan reports the alert again. On the log4shell target, gson went 2.8.8 → 2.8.9. Alert GHSA-4jrv-ppp4-jm57 was open at deploy time, and the first scan after the deploy already resolved it without reporting it again. It stayed purl: None, and vex.openvex.json, csaf-vex.json and vex.cdx.json showed pkg:generic/gson@2.8.8. On prod this would hit every alert open at the 0.4.6 deploy, including all of K-00001's, once it is fixed.

Fix: vex_lifecycle::backfill_purls gives each open alert without a purl the purl of its component in the stored SBOM: the same name (ignoring case) and version, matched as the exports match. It runs:

  • once per tenant at agent start, logged as CVE alerts got their component's purl, before any scan can resolve the alert;
  • at the start of every target scan, before the scan replaces the SBOM, so an alert resolved by that scan still finds its old component.

Not fixable: alerts already resolved whose component has left the SBOM, such as the stage gson alert, keep pkg:generic.

Tests:

  • tests/vex_lifecycle.rs against mongo:7: an alert stored without a purl gets it from the SBOM entry (name in a different case). A second run changes nothing. The component is then removed and the alert resolved. OpenVEX, CycloneDX VEX and CSAF all name pkg:maven/com.google.code.gson/gson@2.8.8, never pkg:generic/gson. An alert that was already resolved is left alone.
  • clippy with the CI flags (agent); fmt.

Stage re-test:

  1. After the deploy, the agent log shows CVE alerts got their component's purl with the number of open alerts.
  2. Take a target with an open alert: in Mongo, cve_alerts has purl set. Update the component and rescan; the alert shows Behoben.
  3. OpenVEX, CycloneDX VEX, CSAF and the Nachweispaket name pkg:maven/… (or the matching ecosystem) for it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

**What was wrong** (A4 re-test on stage): #532 stores the purl when an alert is created, and refreshes it when a scan reports the alert again. On the log4shell target, gson went 2.8.8 → 2.8.9. Alert GHSA-4jrv-ppp4-jm57 was open at deploy time, and the first scan after the deploy already resolved it without reporting it again. It stayed `purl: None`, and `vex.openvex.json`, `csaf-vex.json` and `vex.cdx.json` showed `pkg:generic/gson@2.8.8`. On prod this would hit every alert open at the 0.4.6 deploy, including all of K-00001's, once it is fixed. **Fix:** `vex_lifecycle::backfill_purls` gives each open alert without a purl the purl of its component in the **stored** SBOM: the same name (ignoring case) and version, matched as the exports match. It runs: - once per tenant at agent start, logged as `CVE alerts got their component's purl`, before any scan can resolve the alert; - at the start of every target scan, before the scan replaces the SBOM, so an alert resolved by that scan still finds its old component. **Not fixable:** alerts already resolved whose component has left the SBOM, such as the stage gson alert, keep `pkg:generic`. **Tests:** - `tests/vex_lifecycle.rs` against mongo:7: an alert stored without a purl gets it from the SBOM entry (name in a different case). A second run changes nothing. The component is then removed and the alert resolved. OpenVEX, CycloneDX VEX and CSAF all name `pkg:maven/com.google.code.gson/gson@2.8.8`, never `pkg:generic/gson`. An alert that was already resolved is left alone. - clippy with the CI flags (agent); fmt. **Stage re-test:** 1. After the deploy, the agent log shows `CVE alerts got their component's purl` with the number of open alerts. 2. Take a target with an open alert: in Mongo, `cve_alerts` has `purl` set. Update the component and rescan; the alert shows **Behoben**. 3. OpenVEX, CycloneDX VEX, CSAF and the Nachweispaket name `pkg:maven/…` (or the matching ecosystem) for it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-10-08 22:42:58 +00:00
fix(vex): alerts stored before purls get their component's purl
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
c8c4b46c85
#532 stored the purl on new alerts and refreshed it when a scan reported
an alert again. An alert open at the deploy whose component the first
scan after it removed (stage: gson 2.8.8 -> 2.8.9) was resolved without
ever being reported again, and its VEX/CSAF/CDX exports fell back to
pkg:generic.

vex_lifecycle::backfill_purls gives open alerts without a purl the purl
of their component in the stored SBOM (same name, case aside, and
version, as the exports match it). It runs once per tenant at agent start
and before every target scan, while the SBOM still lists the component.
Alerts already resolved with their component gone cannot be backfilled.

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