From 4448a5394fe1dab59c9dd658efe2035ff9bf6860 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Tue, 6 Oct 2026 14:07:10 +0000 Subject: [PATCH] feat(dashboard): VEX editor and OpenVEX/CycloneDX VEX downloads on the target page (#498, 2/4) (#505) --- compliance-core/src/models/cve.rs | 2 +- compliance-dashboard/assets/main.css | 53 +++ compliance-dashboard/src/components/mod.rs | 1 + .../src/components/vex_panel.rs | 371 ++++++++++++++++++ compliance-dashboard/src/i18n/texts.rs | 141 +++++++ .../src/infrastructure/download.rs | 42 ++ .../src/infrastructure/mod.rs | 2 + .../src/infrastructure/vex.rs | 138 +++++++ compliance-dashboard/src/pages/sbom.rs | 43 +- compliance-dashboard/src/pages/target.rs | 6 + docs/.vitepress/config.mts | 2 + docs/guide/sbom.md | 4 +- docs/guide/vex-en.md | 56 +++ docs/guide/vex.md | 59 +++ .../release/staging-test-plan-after-v0.4.5.md | 27 ++ 15 files changed, 903 insertions(+), 44 deletions(-) create mode 100644 compliance-dashboard/src/components/vex_panel.rs create mode 100644 compliance-dashboard/src/infrastructure/download.rs create mode 100644 compliance-dashboard/src/infrastructure/vex.rs create mode 100644 docs/guide/vex-en.md create mode 100644 docs/guide/vex.md diff --git a/compliance-core/src/models/cve.rs b/compliance-core/src/models/cve.rs index e836cec..aa47628 100644 --- a/compliance-core/src/models/cve.rs +++ b/compliance-core/src/models/cve.rs @@ -62,7 +62,7 @@ pub struct EpssScore { pub date: String, } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct CveAlert { #[serde(rename = "_id", skip_serializing_if = "Option::is_none")] pub id: Option, diff --git a/compliance-dashboard/assets/main.css b/compliance-dashboard/assets/main.css index 4e83b29..82bdf62 100644 --- a/compliance-dashboard/assets/main.css +++ b/compliance-dashboard/assets/main.css @@ -4913,6 +4913,7 @@ tbody tr:last-child td { } .target-open, +.target-vex, .target-manual { margin-bottom: 20px; } @@ -4985,6 +4986,58 @@ tbody tr:last-child td { color: var(--text-tertiary); } +.vex-head { + display: flex; + flex-wrap: wrap; + gap: 12px; + align-items: flex-start; + justify-content: space-between; + margin-bottom: 12px; +} + +.vex-head p { + flex: 1 1 320px; +} + +.vex-exports { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +.vex-table code { + font-family: var(--font-mono); + font-size: 12px; +} + +.vex-editor { + display: grid; + gap: 10px; + max-width: 640px; + padding: 8px 0; +} + +.vex-editor label { + display: grid; + gap: 4px; + font-size: 12.5px; + color: var(--text-secondary); +} + +.vex-editor textarea { + min-height: 60px; +} + +.vex-missing { + font-size: 12.5px; + color: var(--warning); +} + +.vex-editor-actions { + display: flex; + gap: 8px; +} + @media (max-width: 1000px) { .target-summary, .target-columns { diff --git a/compliance-dashboard/src/components/mod.rs b/compliance-dashboard/src/components/mod.rs index 8fc5110..9d69b21 100644 --- a/compliance-dashboard/src/components/mod.rs +++ b/compliance-dashboard/src/components/mod.rs @@ -25,3 +25,4 @@ pub mod sidebar; pub mod support; pub mod theme_toggle; pub mod toast; +pub mod vex_panel; diff --git a/compliance-dashboard/src/components/vex_panel.rs b/compliance-dashboard/src/components/vex_panel.rs new file mode 100644 index 0000000..14554e6 --- /dev/null +++ b/compliance-dashboard/src/components/vex_panel.rs @@ -0,0 +1,371 @@ +//! On a target: its known vulnerabilities with their VEX status, an editor to +//! state whether the product is affected, and the OpenVEX and CycloneDX VEX +//! downloads (#498). Read-only roles see the statements but not the editor. + +use dioxus::prelude::*; +use dioxus_free_icons::icons::bs_icons::BsDownload; +use dioxus_free_icons::Icon; + +use compliance_core::models::{CveAlert, VexJustification, VexStatus}; +use compliance_core::vex_docs::status_of; + +use crate::components::no_access::use_can_write; +use crate::components::severity_badge::SeverityBadge; +use crate::components::toast::{ToastType, Toasts}; +use crate::i18n::texts::{common, vex as tx}; +use crate::i18n::{use_lang, Lang, Text}; +use crate::infrastructure::vex::{ + fetch_target_cves, fetch_vex_export, save_cve_vex, VexFormat, VexStatementDto, +}; + +/// Every status, in the order the editor offers them. +const STATUSES: [VexStatus; 4] = [ + VexStatus::UnderInvestigation, + VexStatus::Affected, + VexStatus::NotAffected, + VexStatus::Fixed, +]; + +/// Every justification, in the order the editor offers them. +const JUSTIFICATIONS: [VexJustification; 5] = [ + VexJustification::ComponentNotPresent, + VexJustification::VulnerableCodeNotPresent, + VexJustification::VulnerableCodeNotInExecutePath, + VexJustification::VulnerableCodeCannotBeControlledByAdversary, + VexJustification::InlineMitigationsAlreadyExist, +]; + +fn status_text(status: VexStatus) -> Text { + match status { + VexStatus::UnderInvestigation => tx::UNDER_INVESTIGATION, + VexStatus::Affected => tx::AFFECTED, + VexStatus::NotAffected => tx::NOT_AFFECTED, + VexStatus::Fixed => tx::FIXED, + } +} + +/// The badge class of a status: red for affected, green for settled. +fn status_class(status: VexStatus) -> &'static str { + match status { + VexStatus::UnderInvestigation => "badge badge-neutral", + VexStatus::Affected => "badge badge-danger", + VexStatus::NotAffected | VexStatus::Fixed => "badge badge-success", + } +} + +fn justification_text(justification: VexJustification) -> Text { + match justification { + VexJustification::ComponentNotPresent => tx::COMPONENT_NOT_PRESENT, + VexJustification::VulnerableCodeNotPresent => tx::CODE_NOT_PRESENT, + VexJustification::VulnerableCodeNotInExecutePath => tx::CODE_NOT_IN_EXECUTE_PATH, + VexJustification::VulnerableCodeCannotBeControlledByAdversary => tx::CODE_NOT_CONTROLLABLE, + VexJustification::InlineMitigationsAlreadyExist => tx::MITIGATIONS_EXIST, + } +} + +/// The wire name of a status or justification (`not_affected`), the value +/// of its `