fix(cve): notifications and tracker issues respect VEX not_affected and fixed #555

Merged
sharang merged 3 commits from fix/notifications-respect-vex into main 2026-10-09 17:07:38 +00:00
Owner

A CVE alert with a VEX statement not_affected or fixed (set by a person, by the scan from Yocto CVE_STATUS / CVE: patches (#551), or from imported OpenVEX) still raised a notification and opened or kept a tracker issue. All target types now follow one rule.

What changes

  • core: CveAlert::is_resolved_by_vex() (true for not_affected / fixed, via VexStatus::resolves()), plus as_str() with the OpenVEX names for statuses and justifications.
  • vex_lifecycle::attach_stored_vex: the scan's in-memory alerts carry no VEX; this gives them the statement stored on the alert, so the helper means something at every call site.
  • cve_notify::notify_new_cves: one notification path, replacing the copies in the orchestrator and the hourly CVE monitor. Skips settled alerts (always on, no flag). Used by the code pipeline, the PLC control-app SBOM path and the monitor.
  • Ordering fix: the code pipeline used to create notifications before the Yocto recipe statements were applied (and upsert_reported withdraws scan statements first), so a recipe's not_affected could never suppress them. Now it runs store → recipe statements → attach VEX → notify → issue sync.
  • cve_issues: a settled CVE never gets a new issue (always on). When the statement is withdrawn (affected, under_investigation or removed), a closed issue is reopened by the existing "found again" path, so no duplicate is created.
  • ISSUE_AUTOCLOSE=off|dry_run|on (new, default off; an unknown value falls back to off with a warning; same pattern as ISSUE_CATCHUP) controls whether an issue that is already open for a settled CVE gets closed:
    • off: it stays open.
    • dry_run: one INFO line per target with tenant_id, target_id, would_close, and the split into not_affected / fixed. Counts only, and no comment, close or label calls.
    • on: the issue is closed with a short bilingual comment naming the VEX status and the justification (or the impact statement), at most 20 per target and scan (the rest in the next scans). One INFO line per target with closed / deferred / failed. Every call goes through GiteaTracker, which waits for the per-instance slot from trackers/gitea_limit.rs (#548). This does not wait for a complete scan, because the statement holds either way.
    • In dry_run and on the summary line is logged on every scan of a target with a tracker, also with would_close=0 / closed=0, so "ran, nothing to close" can be told apart from "didn't run". With off there is no line.
  • .env.example and the docs (guide/issues.md, guide/vex.md, guide/vex-en.md) are updated.

Not changed (on purpose)

  • Notifications created before a statement was set stay as they are, and they count in the bell's unread count (status: new) until someone reads or dismisses them. Dismissing them automatically would also block a fresh notification after a withdrawal (dedup is per CVE, target, package and version), so I left it.
  • The issue reopened after a withdrawal gets the existing comment "Found again by the scan, so reopened."
  • The dashboard CVE/VEX views already show the VEX status, so no change there.

Tests

  • core: models::cve::tests::only_not_affected_and_fixed_resolve_an_alert, models::vex::tests::the_names_are_openvex_s, config::app_env_tests::issue_autoclose_is_off_unless_named
  • agent (Mongo + fake Gitea): pipeline::cve_issues::tests::
    • a_vex_not_affected_or_fixed_closes_the_issue_until_it_is_withdrawn: on. No issue for a settled CVE, closes with a comment, reopens after withdrawal, still one issue.
    • autoclose_off_and_dry_run_leave_the_issue_open: off makes no calls and logs no summary line. dry_run logs the line on every scan, also with would_close=0, and the line contains no titles. dry_run runs against a fake Gitea that refuses and records every write, and no write is made.
    • autoclose_closes_at_most_twenty_per_scan: 22 issues are closed as 20, then 2, then 0.
    • the_vex_comment_names_the_status_and_the_reason
    • The existing tests still pass.
  • agent integration (Mongo): tests/vex_lifecycle.rs::not_affected_and_fixed_raise_no_notification_until_withdrawn covers a person's not_affected/fixed/affected, a recipe's by-scan not_affected, and withdrawal of both.
  • clippy -D warnings for compliance-core and compliance-agent; cargo fmt --check.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

A CVE alert with a VEX statement `not_affected` or `fixed` (set by a person, by the scan from Yocto CVE_STATUS / `CVE:` patches (#551), or from imported OpenVEX) still raised a notification and opened or kept a tracker issue. All target types now follow one rule. ## What changes - **core**: `CveAlert::is_resolved_by_vex()` (true for `not_affected` / `fixed`, via `VexStatus::resolves()`), plus `as_str()` with the OpenVEX names for statuses and justifications. - **`vex_lifecycle::attach_stored_vex`**: the scan's in-memory alerts carry no VEX; this gives them the statement stored on the alert, so the helper means something at every call site. - **`cve_notify::notify_new_cves`**: one notification path, replacing the copies in the orchestrator and the hourly CVE monitor. Skips settled alerts (always on, no flag). Used by the code pipeline, the PLC control-app SBOM path and the monitor. - **Ordering fix**: the code pipeline used to create notifications before the Yocto recipe statements were applied (and `upsert_reported` withdraws scan statements first), so a recipe's `not_affected` could never suppress them. Now it runs store → recipe statements → attach VEX → notify → issue sync. - **`cve_issues`**: a settled CVE never gets a new issue (always on). When the statement is withdrawn (`affected`, `under_investigation` or removed), a closed issue is reopened by the existing "found again" path, so no duplicate is created. - **`ISSUE_AUTOCLOSE=off|dry_run|on`** (new, default `off`; an unknown value falls back to `off` with a warning; same pattern as `ISSUE_CATCHUP`) controls whether an issue that is **already open** for a settled CVE gets closed: - `off`: it stays open. - `dry_run`: one INFO line per target with `tenant_id`, `target_id`, `would_close`, and the split into `not_affected` / `fixed`. Counts only, and no comment, close or label calls. - `on`: the issue is closed with a short bilingual comment naming the VEX status and the justification (or the impact statement), at most 20 per target and scan (the rest in the next scans). One INFO line per target with closed / deferred / failed. Every call goes through `GiteaTracker`, which waits for the per-instance slot from `trackers/gitea_limit.rs` (#548). This does not wait for a complete scan, because the statement holds either way. - In `dry_run` and `on` the summary line is logged on every scan of a target with a tracker, also with `would_close=0` / `closed=0`, so "ran, nothing to close" can be told apart from "didn't run". With `off` there is no line. - `.env.example` and the docs (`guide/issues.md`, `guide/vex.md`, `guide/vex-en.md`) are updated. ## Not changed (on purpose) - Notifications created **before** a statement was set stay as they are, and they count in the bell's unread count (`status: new`) until someone reads or dismisses them. Dismissing them automatically would also block a fresh notification after a withdrawal (dedup is per CVE, target, package and version), so I left it. - The issue reopened after a withdrawal gets the existing comment "Found again by the scan, so reopened." - The dashboard CVE/VEX views already show the VEX status, so no change there. ## Tests - core: `models::cve::tests::only_not_affected_and_fixed_resolve_an_alert`, `models::vex::tests::the_names_are_openvex_s`, `config::app_env_tests::issue_autoclose_is_off_unless_named` - agent (Mongo + fake Gitea): `pipeline::cve_issues::tests::` - `a_vex_not_affected_or_fixed_closes_the_issue_until_it_is_withdrawn`: `on`. No issue for a settled CVE, closes with a comment, reopens after withdrawal, still one issue. - `autoclose_off_and_dry_run_leave_the_issue_open`: `off` makes no calls and logs no summary line. `dry_run` logs the line on every scan, also with `would_close=0`, and the line contains no titles. `dry_run` runs against a fake Gitea that refuses and records every write, and no write is made. - `autoclose_closes_at_most_twenty_per_scan`: 22 issues are closed as 20, then 2, then 0. - `the_vex_comment_names_the_status_and_the_reason` - The existing tests still pass. - agent integration (Mongo): `tests/vex_lifecycle.rs::not_affected_and_fixed_raise_no_notification_until_withdrawn` covers a person's not_affected/fixed/affected, a recipe's by-scan not_affected, and withdrawal of both. - clippy `-D warnings` for compliance-core and compliance-agent; `cargo fmt --check`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 3 commits 2026-10-09 16:57:47 +00:00
A CVE alert whose VEX statement is not_affected or fixed (by a person, by
the scan from Yocto CVE_STATUS / CVE: patches, or imported OpenVEX) still
raised a notification and opened or kept a tracker issue.

- core: CveAlert::is_resolved_by_vex (via VexStatus::resolves), plus
  OpenVEX names for statuses and justifications.
- vex_lifecycle::attach_stored_vex gives the scan's alerts (which carry no
  VEX) the statement stored on the alert.
- cve_notify::notify_new_cves: one notification path for the scans (code and
  PLC control-app) and the hourly CVE monitor; skips settled alerts.
- The code pipeline now notifies after the Yocto statements are applied, so a
  recipe's not_affected suppresses the notification on the first scan too.
- cve_issues: no issue for a settled CVE; an open one is closed with a
  comment naming the VEX status and justification (not gated on a complete
  scan); a withdrawn statement reopens the same issue.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
No new notification or issue for a not_affected/fixed CVE stays always on.
Closing an issue that is already open now depends on ISSUE_AUTOCLOSE
(off | dry_run | on, unknown -> off with a warning), like ISSUE_CATCHUP:
dry_run logs one line per target with the counts per VEX status and makes
no tracker call; on closes at most 20 per target and scan (every Gitea
request waits for its instance's slot) and logs closed/deferred/failed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
fix(cve): the ISSUE_AUTOCLOSE summary line is logged on every scan, also with nothing to close
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 8m35s
e0b9ebee75
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang force-pushed fix/notifications-respect-vex from 9eb7b1a897 to e0b9ebee75 2026-10-09 16:57:47 +00:00 Compare
sharang merged commit 42b25719ec into main 2026-10-09 17:07:38 +00:00
Sign in to join this conversation.