feat(dashboard): CVEs by severity and VEX status as a clickable grid (#957) #962

Merged
sharang merged 1 commits from feat/957-cve-matrix into main 2026-11-10 15:16:06 +00:00
Owner

The first per-repo view from #957: CVEs & VEX. The target page's "Schwachstellen und VEX" card now opens with a chart. The list is one click behind it.

What changed

Dashboard (target page, "Schwachstellen und VEX" card)

  • Grid: one row per severity (kritisch, hoch, mittel, niedrig; "unbekannt" only when an alert has no severity) and one column per VEX status (offen = no statement, in Prüfung, betroffen, nicht betroffen, behoben). Each cell is a real <button> showing that target's count, with aria-label/title like "hoch, offen: 12". Empty cells are disabled, because they would open an empty list.
  • Shading: one blue hue, light to dark (#F5F6FB for 0, then #CDE2FB, #9EC5F4, #5598E7, #256ABF, #104281), with white text on the two darkest. The step is ceil(5 · count / max), so a single CVE is never shaded like none. A small legend ("wenige … viele") explains the scale. Dark mode uses its own steps from the same blues (surface up to light blue, text colour flipped), defined in both dark-theme blocks.
  • Tile: "Offen und noch nicht bewertet: N" is the sum of the offen column. Clicking it opens the list narrowed to offen.
  • Tabelle toggle: shows the same numbers as a plain <table> (caption, th scope). Non-zero counts link to the same narrowed list.
  • Drill-down: a click opens the existing CVE list (VexPanel) filtered to that cell, with the breadcrumb "CVEs › hoch · offen" and "← Zurück zum Diagramm".
  • URL state: the filter goes into the URL: /targets/{id}?cve_severity=high&cve_vex=open. Either side can be left out (the tile uses ?cve_vex=open). ?cve_vex=all opens the whole list as before.
  • Liste und Exporte: this button opens the unfiltered panel, including the OpenVEX, CycloneDX VEX and CSAF exports.
  • Texts: DE and EN in the new i18n::texts::cve_matrix module. Styles are small cve-* classes appended to the end of main.css.

Shared bucketing (compliance-core/src/cve_matrix.rs, new)

  • CveSeverity::of(word, cvss): the advisory's word comes first (CRITICAL/HIGH/MEDIUM/MODERATE/LOW, any case). If the word is missing or not one of these, the CVSS score decides (≥9 / ≥7 / ≥4 / below). With neither, the severity is Unknown.
  • VexColumn::of(status): no statement → Open; each VexStatus maps to its own column. This deliberately differs from vex_docs::status_of, which exports "no statement" as under_investigation.
  • CveMatrix holds the counts. CveFilter::matches is used by the dashboard to narrow the list. Agent and dashboard bucket with the same code, so a cell's number and the length of its list cannot drift apart.

Agent

  • New handler api/handlers/cve_matrix.rs plus one route line.
  • Mongo find with resolved_at: null (this matches a missing field and an explicit null) and a projection on severity, cvss_score and vex.status. Bucketing happens in Rust.

API

GET /api/v1/targets/{id}/cve-matrix

{
  "data": {
    "cells": [
      { "severity": "high", "vex": "open", "count": 12 },
      { "severity": "medium", "vex": "not_affected", "count": 7 }
    ]
  },
  "total": 19
}
  • Only non-empty cells are listed, rows top to bottom, columns left to right.
  • severity is one of critical|high|medium|low|unknown.
  • vex is one of open|under_investigation|affected|not_affected|fixed.
  • Only still-reported alerts are counted (resolved_at unset).
  • Scoped like GET /api/v1/targets/{id}/cves: tenant_db plus repo_id. It is a GET, so the org-role middleware lets the read-only roles in. Like /cves, it is not in KEY_SCOPES.

Files outside the new ones

  • components/vex_panel.rs has three small changes, so #949 can rebase easily:
    • one use compliance_core::cve_matrix::CveFilter;
    • an optional prop #[props(default)] filter: Option<CveFilter>
    • .filter(|a| filter.is_none_or(|f| f.matches(a))) on the row iterator
  • api/handlers/vex.rs is not touched. /cves did not need new query params, because the narrowing happens on the already-loaded list using the shared CveFilter.
  • app.rs: TargetPage gains two optional query fields, plus a Route::target(id) helper. The 4 existing Route::TargetPage { id } call sites (targets, compliance, graph explorer) now use the helper.
  • docs/guide/sbom.md: the new endpoint is added to the API paragraph.

Known behaviour

  • Resolved alerts: the grid leaves out alerts a complete scan no longer found (resolved_at set). Narrowed lists match the grid counts exactly. The unfiltered "Liste und Exporte" list is the panel as before and still shows resolved alerts.
  • "offen" vs. "in Prüfung" badge: the grid separates "offen" (no statement) from "in Prüfung" (an explicit statement). The list's status badge still goes through status_of and shows both as "in Prüfung". The grid's hint text says so. The badge belongs to #949's part of the UI.
  • Severity badge vs. row: an alert with an unusual severity word but a CVSS score (e.g. important, 8.1) sits in the "hoch" row, but its list badge reads the word only and shows "info".
  • After a VEX change: when you state a VEX in a narrowed list, the alert leaves that cell. The panel reloads and can show a table with only the header. Fixing that needs a bigger vex_panel.rs change, so it is left for later.
  • Trailing ?: Route::target(id) renders as /targets/{id}?, because the router always writes the ? of a two-argument query. This is harmless and covered by a test.

Follow-up with #949

Once #949 (CVEs grouped by package) has merged, a cell click should open #949's package cards for that cell instead of the plain list, and the single CVEs from there, as #957 describes. The CveFilter passed to the CVE list is the handoff point.

How tested

  • cargo fmt --all --check: ok
  • RUSTFLAGS="-D warnings" cargo clippy -p compliance-agent --all-targets -j8 -- -D warnings: clean
  • RUSTFLAGS="-D warnings" cargo clippy -p compliance-dashboard --features server --no-default-features --all-targets -j8 -- -D warnings: clean
  • RUSTFLAGS="-D warnings" cargo clippy -p compliance-dashboard --features web --no-default-features --all-targets -j8 -- -D warnings: clean
  • RUSTFLAGS="-D warnings" cargo clippy -p compliance-core --all-targets -j8 -- -D warnings: clean
  • compliance-core cve_matrix: 8 unit tests and 1 doctest, all pass. They cover:
    • severity in any case, MODERATE → mittel
    • the CVSS fallback, and Unknown when there is no word and no score
    • each VEX column, with no statement → offen
    • wire names round-trip
    • counting, total, max and unassessed
    • the "unbekannt" row appearing only when needed
    • the filter, which never passes a resolved alert
  • compliance-agent cve_matrix: 2 tests pass. One checks the resolved_at: null filter; the other checks that a projected row is bucketed like the alert.
  • compliance-dashboard (server): 131 tests pass, including the new tests for:
    • URL ⇄ selection
    • shade steps
    • aria labels and breadcrumb
    • route query round-trip
    • texts
  • compliance-agent role-gate and route tests pass.
  • The grid markup and CSS were rendered statically in light and dark mode and checked by eye. There was no live end-to-end run against an agent with real alerts.

Part of #957

🤖 Generated with Claude Code

The first per-repo view from #957: **CVEs & VEX**. The target page's "Schwachstellen und VEX" card now opens with a chart. The list is one click behind it. ## What changed **Dashboard (target page, "Schwachstellen und VEX" card)** - **Grid:** one row per severity (kritisch, hoch, mittel, niedrig; "unbekannt" only when an alert has no severity) and one column per VEX status (offen = no statement, in Prüfung, betroffen, nicht betroffen, behoben). Each cell is a real `<button>` showing that target's count, with `aria-label`/`title` like "hoch, offen: 12". Empty cells are `disabled`, because they would open an empty list. - **Shading:** one blue hue, light to dark (`#F5F6FB` for 0, then `#CDE2FB`, `#9EC5F4`, `#5598E7`, `#256ABF`, `#104281`), with white text on the two darkest. The step is `ceil(5 · count / max)`, so a single CVE is never shaded like none. A small legend ("wenige … viele") explains the scale. Dark mode uses its own steps from the same blues (surface up to light blue, text colour flipped), defined in both dark-theme blocks. - **Tile:** "Offen und noch nicht bewertet: N" is the sum of the *offen* column. Clicking it opens the list narrowed to `offen`. - **Tabelle toggle:** shows the same numbers as a plain `<table>` (caption, `th scope`). Non-zero counts link to the same narrowed list. - **Drill-down:** a click opens the existing CVE list (`VexPanel`) filtered to that cell, with the breadcrumb "CVEs › hoch · offen" and "← Zurück zum Diagramm". - **URL state:** the filter goes into the URL: `/targets/{id}?cve_severity=high&cve_vex=open`. Either side can be left out (the tile uses `?cve_vex=open`). `?cve_vex=all` opens the whole list as before. - **Liste und Exporte:** this button opens the unfiltered panel, including the OpenVEX, CycloneDX VEX and CSAF exports. - **Texts:** DE and EN in the new `i18n::texts::cve_matrix` module. Styles are small `cve-*` classes appended to the end of `main.css`. **Shared bucketing (`compliance-core/src/cve_matrix.rs`, new)** - `CveSeverity::of(word, cvss)`: the advisory's word comes first (`CRITICAL`/`HIGH`/`MEDIUM`/`MODERATE`/`LOW`, any case). If the word is missing or not one of these, the CVSS score decides (≥9 / ≥7 / ≥4 / below). With neither, the severity is `Unknown`. - `VexColumn::of(status)`: no statement → `Open`; each `VexStatus` maps to its own column. This deliberately differs from `vex_docs::status_of`, which exports "no statement" as `under_investigation`. - `CveMatrix` holds the counts. `CveFilter::matches` is used by the dashboard to narrow the list. Agent and dashboard bucket with the same code, so a cell's number and the length of its list cannot drift apart. **Agent** - New handler `api/handlers/cve_matrix.rs` plus one route line. - Mongo `find` with `resolved_at: null` (this matches a missing field and an explicit null) and a projection on `severity`, `cvss_score` and `vex.status`. Bucketing happens in Rust. ## API `GET /api/v1/targets/{id}/cve-matrix` ```json { "data": { "cells": [ { "severity": "high", "vex": "open", "count": 12 }, { "severity": "medium", "vex": "not_affected", "count": 7 } ] }, "total": 19 } ``` - Only non-empty cells are listed, rows top to bottom, columns left to right. - `severity` is one of `critical|high|medium|low|unknown`. - `vex` is one of `open|under_investigation|affected|not_affected|fixed`. - Only still-reported alerts are counted (`resolved_at` unset). - Scoped like `GET /api/v1/targets/{id}/cves`: `tenant_db` plus `repo_id`. It is a GET, so the org-role middleware lets the read-only roles in. Like `/cves`, it is not in `KEY_SCOPES`. ## Files outside the new ones - `components/vex_panel.rs` has three small changes, so #949 can rebase easily: - one `use compliance_core::cve_matrix::CveFilter;` - an optional prop `#[props(default)] filter: Option<CveFilter>` - `.filter(|a| filter.is_none_or(|f| f.matches(a)))` on the row iterator - `api/handlers/vex.rs` is not touched. `/cves` did not need new query params, because the narrowing happens on the already-loaded list using the shared `CveFilter`. - `app.rs`: `TargetPage` gains two optional query fields, plus a `Route::target(id)` helper. The 4 existing `Route::TargetPage { id }` call sites (targets, compliance, graph explorer) now use the helper. - `docs/guide/sbom.md`: the new endpoint is added to the API paragraph. ## Known behaviour - **Resolved alerts:** the grid leaves out alerts a complete scan no longer found (`resolved_at` set). Narrowed lists match the grid counts exactly. The unfiltered "Liste und Exporte" list is the panel as before and still shows resolved alerts. - **"offen" vs. "in Prüfung" badge:** the grid separates "offen" (no statement) from "in Prüfung" (an explicit statement). The list's status badge still goes through `status_of` and shows both as "in Prüfung". The grid's hint text says so. The badge belongs to #949's part of the UI. - **Severity badge vs. row:** an alert with an unusual severity word but a CVSS score (e.g. `important`, 8.1) sits in the "hoch" row, but its list badge reads the word only and shows "info". - **After a VEX change:** when you state a VEX in a narrowed list, the alert leaves that cell. The panel reloads and can show a table with only the header. Fixing that needs a bigger `vex_panel.rs` change, so it is left for later. - **Trailing `?`:** `Route::target(id)` renders as `/targets/{id}?`, because the router always writes the `?` of a two-argument query. This is harmless and covered by a test. ## Follow-up with #949 Once #949 (CVEs grouped by package) has merged, a cell click should open #949's package cards for that cell instead of the plain list, and the single CVEs from there, as #957 describes. The `CveFilter` passed to the CVE list is the handoff point. ## How tested - `cargo fmt --all --check`: ok - `RUSTFLAGS="-D warnings" cargo clippy -p compliance-agent --all-targets -j8 -- -D warnings`: clean - `RUSTFLAGS="-D warnings" cargo clippy -p compliance-dashboard --features server --no-default-features --all-targets -j8 -- -D warnings`: clean - `RUSTFLAGS="-D warnings" cargo clippy -p compliance-dashboard --features web --no-default-features --all-targets -j8 -- -D warnings`: clean - `RUSTFLAGS="-D warnings" cargo clippy -p compliance-core --all-targets -j8 -- -D warnings`: clean - `compliance-core` `cve_matrix`: 8 unit tests and 1 doctest, all pass. They cover: - severity in any case, `MODERATE` → mittel - the CVSS fallback, and `Unknown` when there is no word and no score - each VEX column, with no statement → offen - wire names round-trip - counting, total, max and unassessed - the "unbekannt" row appearing only when needed - the filter, which never passes a resolved alert - `compliance-agent` `cve_matrix`: 2 tests pass. One checks the `resolved_at: null` filter; the other checks that a projected row is bucketed like the alert. - `compliance-dashboard` (server): 131 tests pass, including the new tests for: - URL ⇄ selection - shade steps - aria labels and breadcrumb - route query round-trip - texts - `compliance-agent` role-gate and route tests pass. - The grid markup and CSS were rendered statically in light and dark mode and checked by eye. **There was no live end-to-end run** against an agent with real alerts. Part of #957 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-10 14:56:24 +00:00
feat(dashboard): CVEs by severity and VEX status as a clickable grid (#957)
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 3m51s
CI / Check (pull_request) Successful in 18m47s
2c71385989
The target's "Schwachstellen und VEX" card now opens with a grid of
severity rows against VEX-status columns (offen, in Pruefung, betroffen,
nicht betroffen, behoben), each count shaded on one blue scale and a
button into the CVE list narrowed to that cell. The choice sits in the
URL (?cve_severity=high&cve_vex=open), with a breadcrumb and a way back;
a table toggle shows the same numbers, and a tile counts the CVEs nobody
has assessed yet.

The agent counts the still-reported alerts in
GET /api/v1/targets/{id}/cve-matrix; the bucketing lives in
compliance-core so the dashboard narrows the list the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang force-pushed feat/957-cve-matrix from 7799a98bb4 to 2c71385989 2026-11-10 14:56:24 +00:00 Compare
Author
Owner

Rebased onto main after #959 (CVE groups) and #966 (components view). The conflicts were resolved as follows:

  • compliance-core/src/lib.rs, main.css, texts.rs, app.rs: both sides added a module, a style block or a test, and all are kept.
  • components/vex_panel.rs: the imports are the union of both sides, and #959's grouped/single view is kept. While a grid cell's filter is set (filter: Some), the panel shows that cell's alerts as single rows (CveTable), because #959's package groups cover all open alerts, not one cell. Without a filter, it shows #959's toggle as before.

Checked locally: fmt, clippy -D warnings for compliance-core and compliance-dashboard (server and web), the dashboard lib tests (141) and the core CVE tests (16).

Rebased onto main after #959 (CVE groups) and #966 (components view). The conflicts were resolved as follows: - `compliance-core/src/lib.rs`, `main.css`, `texts.rs`, `app.rs`: both sides added a module, a style block or a test, and all are kept. - `components/vex_panel.rs`: the imports are the union of both sides, and #959's grouped/single view is kept. While a grid cell's filter is set (`filter: Some`), the panel shows that cell's alerts as single rows (`CveTable`), because #959's package groups cover all open alerts, not one cell. Without a filter, it shows #959's toggle as before. Checked locally: fmt, clippy `-D warnings` for compliance-core and compliance-dashboard (server and web), the dashboard lib tests (141) and the core CVE tests (16).
sharang merged commit 32cd11bb2f into main 2026-11-10 15:16:06 +00:00
Sign in to join this conversation.