feat(dashboard): VEX editor and OpenVEX/CycloneDX VEX downloads on the target page (#498, 2/4) (#505)
This commit was merged in pull request #505.
This commit is contained in:
1 parent
63a2bf2bcb
commit
4448a5394f
15 files changed
+903
-44
No files matched your search
@@ -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<bson::oid::ObjectId>,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -25,3 +25,4 @@ pub mod sidebar;
|
||||
pub mod support;
|
||||
pub mod theme_toggle;
|
||||
pub mod toast;
|
||||
pub mod vex_panel;
|
||||
@@ -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 `<option>`.
|
||||
fn wire<T: serde::Serialize>(value: T) -> String {
|
||||
crate::infrastructure::findings::wire_name(&value)
|
||||
}
|
||||
|
||||
/// The value an `<option>` named with [`wire`] stands for.
|
||||
fn from_wire<T: serde::de::DeserializeOwned>(name: &str) -> Option<T> {
|
||||
serde_json::from_value(serde_json::Value::String(name.to_string())).ok()
|
||||
}
|
||||
|
||||
/// Why `statement` cannot be saved yet, as the agent would refuse it.
|
||||
fn missing(statement: &VexStatementDto) -> Option<Text> {
|
||||
let has = |s: &Option<String>| s.as_deref().is_some_and(|t| !t.trim().is_empty());
|
||||
match statement.status {
|
||||
VexStatus::NotAffected
|
||||
if statement.justification.is_none() && !has(&statement.impact_statement) =>
|
||||
{
|
||||
Some(tx::NEEDS_REASON)
|
||||
}
|
||||
VexStatus::Affected if !has(&statement.action_statement) => Some(tx::NEEDS_ACTION),
|
||||
VexStatus::UnderInvestigation
|
||||
| VexStatus::Affected
|
||||
| VexStatus::NotAffected
|
||||
| VexStatus::Fixed => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Who made an alert's statement: the person's name, "Prüfung" for a scan.
|
||||
fn stated_by(alert: &CveAlert, lang: Lang) -> String {
|
||||
match &alert.vex {
|
||||
Some(vex) if vex.by_scan => tx::BY_SCAN.get(lang).to_string(),
|
||||
Some(vex) => vex.by_name.clone().unwrap_or_else(|| vex.by.clone()),
|
||||
None => String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The "Schwachstellen und VEX" card body for target `target_id`.
|
||||
#[component]
|
||||
pub fn VexPanel(target_id: String) -> Element {
|
||||
let lang = use_lang()();
|
||||
let can_write = use_can_write();
|
||||
let id_for_load = target_id.clone();
|
||||
let mut alerts = use_resource(move || {
|
||||
let id = id_for_load.clone();
|
||||
async move { fetch_target_cves(id).await.ok() }
|
||||
});
|
||||
let mut editing = use_signal(|| Option::<String>::None);
|
||||
|
||||
rsx! {
|
||||
div { class: "vex-head",
|
||||
p { class: "target-muted", {tx::HINT.get(lang)} }
|
||||
div { class: "vex-exports",
|
||||
for format in [VexFormat::OpenVex, VexFormat::CycloneDx] {
|
||||
VexExportButton { target_id: target_id.clone(), format }
|
||||
}
|
||||
}
|
||||
}
|
||||
match &*alerts.read() {
|
||||
None => rsx! { div { class: "loading", {common::LOADING.get(lang)} } },
|
||||
Some(None) => rsx! { p { class: "target-muted", {tx::LOAD_FAILED.get(lang)} } },
|
||||
Some(Some(list)) if list.is_empty() => rsx! { p { class: "target-muted", {tx::NONE.get(lang)} } },
|
||||
Some(Some(list)) => rsx! {
|
||||
div { class: "table-wrapper",
|
||||
table { class: "vex-table",
|
||||
thead {
|
||||
tr {
|
||||
th { {tx::CVE.get(lang)} }
|
||||
th { {tx::COMPONENT.get(lang)} }
|
||||
th { {tx::SEVERITY.get(lang)} }
|
||||
th { {tx::STATUS.get(lang)} }
|
||||
th { {tx::STATED_BY.get(lang)} }
|
||||
th {}
|
||||
}
|
||||
}
|
||||
tbody {
|
||||
for alert in list.iter() {
|
||||
{
|
||||
let alert_id = alert.id.map(|o| o.to_hex()).unwrap_or_default();
|
||||
let status = status_of(alert);
|
||||
let open = editing.read().as_deref() == Some(alert_id.as_str());
|
||||
let edit_id = alert_id.clone();
|
||||
rsx! {
|
||||
tr { key: "{alert_id}",
|
||||
td { code { "{alert.cve_id}" } }
|
||||
td { "{alert.affected_package} {alert.affected_version}" }
|
||||
td {
|
||||
if let Some(sev) = alert.severity.as_deref() {
|
||||
SeverityBadge { severity: sev.to_string() }
|
||||
}
|
||||
}
|
||||
td { span { class: status_class(status), {status_text(status).get(lang)} } }
|
||||
td { class: "target-muted", "{stated_by(alert, lang)}" }
|
||||
td {
|
||||
if can_write && !open {
|
||||
button {
|
||||
class: "btn btn-ghost btn-sm",
|
||||
onclick: move |_| editing.set(Some(edit_id.clone())),
|
||||
{tx::EDIT.get(lang)}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if open {
|
||||
tr { class: "vex-editor-row",
|
||||
td { colspan: "6",
|
||||
VexEditor {
|
||||
alert: alert.clone(),
|
||||
on_close: move |saved: bool| {
|
||||
editing.set(None);
|
||||
if saved {
|
||||
alerts.restart();
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Download the target's VEX in `format`; a refusal shows as a toast.
|
||||
#[component]
|
||||
fn VexExportButton(target_id: String, format: VexFormat) -> Element {
|
||||
let lang = use_lang()();
|
||||
let mut toasts = use_context::<Toasts>();
|
||||
let mut busy = use_signal(|| false);
|
||||
let label = match format {
|
||||
VexFormat::OpenVex => tx::EXPORT_OPENVEX,
|
||||
VexFormat::CycloneDx => tx::EXPORT_CYCLONEDX,
|
||||
};
|
||||
rsx! {
|
||||
button {
|
||||
class: "btn btn-secondary btn-sm",
|
||||
disabled: busy(),
|
||||
onclick: move |_| {
|
||||
let id = target_id.clone();
|
||||
busy.set(true);
|
||||
spawn(async move {
|
||||
match fetch_vex_export(id.clone(), format).await {
|
||||
Ok(json) => crate::infrastructure::download::save_json(&json, &format.filename(&id)),
|
||||
Err(e) => toasts.push(ToastType::Error, format!("{}: {e}", tx::EXPORT_FAILED.get(lang))),
|
||||
}
|
||||
busy.set(false);
|
||||
});
|
||||
},
|
||||
Icon { icon: BsDownload, width: 14, height: 14 }
|
||||
{label.get(lang)}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The statement editor for one alert, starting from its current statement.
|
||||
/// `on_close` gets whether a statement was saved.
|
||||
#[component]
|
||||
fn VexEditor(alert: CveAlert, on_close: EventHandler<bool>) -> Element {
|
||||
let lang = use_lang()();
|
||||
let mut toasts = use_context::<Toasts>();
|
||||
let current = alert.vex.clone().filter(|v| !v.by_scan);
|
||||
let mut status = use_signal(|| current.as_ref().map_or(status_of(&alert), |v| v.status));
|
||||
let mut justification = use_signal(|| current.as_ref().and_then(|v| v.justification));
|
||||
let mut impact = use_signal(|| {
|
||||
current
|
||||
.as_ref()
|
||||
.and_then(|v| v.impact_statement.clone())
|
||||
.unwrap_or_default()
|
||||
});
|
||||
let mut action = use_signal(|| {
|
||||
current
|
||||
.as_ref()
|
||||
.and_then(|v| v.action_statement.clone())
|
||||
.unwrap_or_default()
|
||||
});
|
||||
let mut busy = use_signal(|| false);
|
||||
|
||||
// Only the fields the chosen status uses are sent.
|
||||
let filled = |s: String| (!s.trim().is_empty()).then_some(s);
|
||||
let not_affected = status() == VexStatus::NotAffected;
|
||||
let statement = VexStatementDto {
|
||||
status: status(),
|
||||
justification: justification().filter(|_| not_affected),
|
||||
impact_statement: filled(impact()).filter(|_| not_affected),
|
||||
action_statement: filled(action()).filter(|_| status() == VexStatus::Affected),
|
||||
};
|
||||
let blocked = missing(&statement);
|
||||
let alert_id = alert.id.map(|o| o.to_hex()).unwrap_or_default();
|
||||
|
||||
rsx! {
|
||||
div { class: "vex-editor",
|
||||
label {
|
||||
{tx::STATUS.get(lang)}
|
||||
select {
|
||||
onchange: move |e| {
|
||||
if let Some(s) = from_wire(&e.value()) {
|
||||
status.set(s);
|
||||
}
|
||||
},
|
||||
for s in STATUSES {
|
||||
option { value: wire(s), selected: status() == s, {status_text(s).get(lang)} }
|
||||
}
|
||||
}
|
||||
}
|
||||
if status() == VexStatus::NotAffected {
|
||||
label {
|
||||
{tx::JUSTIFICATION.get(lang)}
|
||||
select {
|
||||
onchange: move |e| justification.set(from_wire(&e.value())),
|
||||
option { value: "", selected: justification().is_none(), {tx::NO_JUSTIFICATION.get(lang)} }
|
||||
for j in JUSTIFICATIONS {
|
||||
option { value: wire(j), selected: justification() == Some(j), {justification_text(j).get(lang)} }
|
||||
}
|
||||
}
|
||||
}
|
||||
label {
|
||||
{tx::IMPACT_STATEMENT.get(lang)}
|
||||
textarea { value: "{impact}", oninput: move |e| impact.set(e.value()) }
|
||||
}
|
||||
}
|
||||
if status() == VexStatus::Affected {
|
||||
label {
|
||||
{tx::ACTION_STATEMENT.get(lang)}
|
||||
textarea { value: "{action}", oninput: move |e| action.set(e.value()) }
|
||||
}
|
||||
}
|
||||
if let Some(reason) = blocked {
|
||||
p { class: "vex-missing", {reason.get(lang)} }
|
||||
}
|
||||
div { class: "vex-editor-actions",
|
||||
button {
|
||||
class: "btn btn-primary btn-sm",
|
||||
disabled: busy() || blocked.is_some(),
|
||||
onclick: move |_| {
|
||||
let (id, body) = (alert_id.clone(), statement.clone());
|
||||
busy.set(true);
|
||||
spawn(async move {
|
||||
match save_cve_vex(id, body).await {
|
||||
Ok(()) => {
|
||||
toasts.push(ToastType::Success, tx::SAVED.get(lang));
|
||||
on_close.call(true);
|
||||
}
|
||||
Err(e) => {
|
||||
toasts.push(ToastType::Error, format!("{}: {e}", tx::SAVE_FAILED.get(lang)));
|
||||
busy.set(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
{tx::SAVE.get(lang)}
|
||||
}
|
||||
button {
|
||||
class: "btn btn-ghost btn-sm",
|
||||
onclick: move |_| on_close.call(false),
|
||||
{tx::CANCEL.get(lang)}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn statement(status: VexStatus) -> VexStatementDto {
|
||||
VexStatementDto {
|
||||
status,
|
||||
justification: None,
|
||||
impact_statement: None,
|
||||
action_statement: None,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_editor_asks_for_what_the_agent_requires() {
|
||||
assert_eq!(
|
||||
missing(&statement(VexStatus::NotAffected)),
|
||||
Some(tx::NEEDS_REASON)
|
||||
);
|
||||
let mut reasoned = statement(VexStatus::NotAffected);
|
||||
reasoned.impact_statement = Some("Only used at build time.".into());
|
||||
assert_eq!(missing(&reasoned), None);
|
||||
let mut blank = statement(VexStatus::Affected);
|
||||
blank.action_statement = Some(" ".into());
|
||||
assert_eq!(missing(&blank), Some(tx::NEEDS_ACTION));
|
||||
assert_eq!(missing(&statement(VexStatus::Fixed)), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn options_round_trip_through_their_wire_names() {
|
||||
for s in STATUSES {
|
||||
assert_eq!(from_wire::<VexStatus>(&wire(s)), Some(s));
|
||||
}
|
||||
for j in JUSTIFICATIONS {
|
||||
assert_eq!(from_wire::<VexJustification>(&wire(j)), Some(j));
|
||||
}
|
||||
assert_eq!(from_wire::<VexJustification>(""), None);
|
||||
}
|
||||
}
|
||||
@@ -2251,6 +2251,147 @@ pub mod manual {
|
||||
}
|
||||
|
||||
/// The CRA compliance view of a target.
|
||||
pub mod vex {
|
||||
use super::Text;
|
||||
|
||||
pub const TITLE: Text = Text {
|
||||
de: "Schwachstellen und VEX",
|
||||
en: "Vulnerabilities and VEX",
|
||||
};
|
||||
pub const HINT: Text = Text {
|
||||
de: "Für jede bekannte Schwachstelle Ihrer Komponenten halten Sie fest, ob Ihr \
|
||||
Produkt betroffen ist (VEX). Ohne Aussage gilt sie als in Prüfung; findet eine \
|
||||
vollständige Prüfung sie nicht mehr, gilt sie als behoben.",
|
||||
en: "For each known vulnerability of your components, state whether your product \
|
||||
is affected (VEX). Without a statement it is under investigation; once a \
|
||||
complete scan no longer finds it, it is fixed.",
|
||||
};
|
||||
pub const NONE: Text = Text {
|
||||
de: "Keine bekannten Schwachstellen in den Komponenten dieses Ziels.",
|
||||
en: "No known vulnerabilities in this target's components.",
|
||||
};
|
||||
pub const LOAD_FAILED: Text = Text {
|
||||
de: "Die Schwachstellen konnten nicht geladen werden",
|
||||
en: "The vulnerabilities could not be loaded",
|
||||
};
|
||||
pub const EXPORT_OPENVEX: Text = Text {
|
||||
de: "OpenVEX herunterladen",
|
||||
en: "Download OpenVEX",
|
||||
};
|
||||
pub const EXPORT_CYCLONEDX: Text = Text {
|
||||
de: "CycloneDX VEX herunterladen",
|
||||
en: "Download CycloneDX VEX",
|
||||
};
|
||||
pub const EXPORT_FAILED: Text = Text {
|
||||
de: "Der VEX-Export ist fehlgeschlagen",
|
||||
en: "The VEX export failed",
|
||||
};
|
||||
pub const CVE: Text = Text {
|
||||
de: "Schwachstelle",
|
||||
en: "Vulnerability",
|
||||
};
|
||||
pub const COMPONENT: Text = Text {
|
||||
de: "Komponente",
|
||||
en: "Component",
|
||||
};
|
||||
pub const SEVERITY: Text = Text {
|
||||
de: "Schweregrad",
|
||||
en: "Severity",
|
||||
};
|
||||
pub const STATUS: Text = Text {
|
||||
de: "Status",
|
||||
en: "Status",
|
||||
};
|
||||
pub const STATED_BY: Text = Text {
|
||||
de: "Aussage von",
|
||||
en: "Stated by",
|
||||
};
|
||||
pub const BY_SCAN: Text = Text {
|
||||
de: "Prüfung",
|
||||
en: "Scan",
|
||||
};
|
||||
pub const EDIT: Text = Text {
|
||||
de: "Bewerten",
|
||||
en: "Assess",
|
||||
};
|
||||
pub const UNDER_INVESTIGATION: Text = Text {
|
||||
de: "In Prüfung",
|
||||
en: "Under investigation",
|
||||
};
|
||||
pub const AFFECTED: Text = Text {
|
||||
de: "Betroffen",
|
||||
en: "Affected",
|
||||
};
|
||||
pub const NOT_AFFECTED: Text = Text {
|
||||
de: "Nicht betroffen",
|
||||
en: "Not affected",
|
||||
};
|
||||
pub const FIXED: Text = Text {
|
||||
de: "Behoben",
|
||||
en: "Fixed",
|
||||
};
|
||||
pub const JUSTIFICATION: Text = Text {
|
||||
de: "Begründung",
|
||||
en: "Justification",
|
||||
};
|
||||
pub const NO_JUSTIFICATION: Text = Text {
|
||||
de: "Keine (Freitext unten)",
|
||||
en: "None (statement below)",
|
||||
};
|
||||
pub const COMPONENT_NOT_PRESENT: Text = Text {
|
||||
de: "Komponente nicht enthalten",
|
||||
en: "Component not present",
|
||||
};
|
||||
pub const CODE_NOT_PRESENT: Text = Text {
|
||||
de: "Verwundbarer Code nicht enthalten",
|
||||
en: "Vulnerable code not present",
|
||||
};
|
||||
pub const CODE_NOT_IN_EXECUTE_PATH: Text = Text {
|
||||
de: "Verwundbarer Code wird nicht ausgeführt",
|
||||
en: "Vulnerable code not in execute path",
|
||||
};
|
||||
pub const CODE_NOT_CONTROLLABLE: Text = Text {
|
||||
de: "Nicht durch Angreifer steuerbar",
|
||||
en: "Cannot be controlled by an adversary",
|
||||
};
|
||||
pub const MITIGATIONS_EXIST: Text = Text {
|
||||
de: "Schutzmaßnahmen bereits vorhanden",
|
||||
en: "Inline mitigations already exist",
|
||||
};
|
||||
pub const IMPACT_STATEMENT: Text = Text {
|
||||
de: "Warum nicht betroffen",
|
||||
en: "Why not affected",
|
||||
};
|
||||
pub const ACTION_STATEMENT: Text = Text {
|
||||
de: "Was Nutzer tun müssen",
|
||||
en: "What users must do",
|
||||
};
|
||||
pub const NEEDS_REASON: Text = Text {
|
||||
de: "\"Nicht betroffen\" braucht eine Begründung oder einen Freitext.",
|
||||
en: "\"Not affected\" needs a justification or a statement.",
|
||||
};
|
||||
pub const NEEDS_ACTION: Text = Text {
|
||||
de: "\"Betroffen\" braucht eine Handlungsanweisung für Nutzer.",
|
||||
en: "\"Affected\" needs an action statement for users.",
|
||||
};
|
||||
pub const SAVE: Text = Text {
|
||||
de: "Speichern",
|
||||
en: "Save",
|
||||
};
|
||||
pub const CANCEL: Text = Text {
|
||||
de: "Abbrechen",
|
||||
en: "Cancel",
|
||||
};
|
||||
pub const SAVED: Text = Text {
|
||||
de: "VEX-Aussage gespeichert",
|
||||
en: "VEX statement saved",
|
||||
};
|
||||
pub const SAVE_FAILED: Text = Text {
|
||||
de: "Die VEX-Aussage wurde nicht gespeichert",
|
||||
en: "The VEX statement was not saved",
|
||||
};
|
||||
}
|
||||
|
||||
pub mod compliance {
|
||||
use super::Text;
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//! Save text the page fetched as a file in the browser.
|
||||
|
||||
/// Save `content` as the JSON file `filename`.
|
||||
#[cfg(feature = "web")]
|
||||
pub fn save_json(content: &str, filename: &str) {
|
||||
use wasm_bindgen::JsCast;
|
||||
let Some(window) = web_sys::window() else {
|
||||
return;
|
||||
};
|
||||
let Some(document) = window.document() else {
|
||||
return;
|
||||
};
|
||||
|
||||
let blob_parts = js_sys::Array::new();
|
||||
blob_parts.push(&wasm_bindgen::JsValue::from_str(content));
|
||||
|
||||
let opts = web_sys::BlobPropertyBag::new();
|
||||
opts.set_type("application/json");
|
||||
let Ok(blob) = web_sys::Blob::new_with_str_sequence_and_options(&blob_parts, &opts) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Ok(url) = web_sys::Url::create_object_url_with_blob(&blob) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Ok(el) = document.create_element("a") else {
|
||||
return;
|
||||
};
|
||||
let Ok(a) = el.dyn_into::<web_sys::HtmlAnchorElement>() else {
|
||||
return;
|
||||
};
|
||||
a.set_href(&url);
|
||||
a.set_download(filename);
|
||||
a.click();
|
||||
|
||||
let _ = web_sys::Url::revoke_object_url(&url);
|
||||
}
|
||||
|
||||
/// Server rendering: downloads only happen in the browser.
|
||||
#[cfg(not(feature = "web"))]
|
||||
pub fn save_json(_content: &str, _filename: &str) {}
|
||||
@@ -3,6 +3,7 @@
|
||||
pub mod auth_check;
|
||||
pub mod chat;
|
||||
pub mod dast;
|
||||
pub mod download;
|
||||
pub mod evidence;
|
||||
pub mod findings;
|
||||
pub mod graph;
|
||||
@@ -21,6 +22,7 @@ pub mod sbom;
|
||||
pub mod scans;
|
||||
pub mod stats;
|
||||
pub mod support;
|
||||
pub mod vex;
|
||||
|
||||
// Server-only modules
|
||||
#[cfg(feature = "server")]
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
//! VEX statements on a target's CVE alerts (#498): list the alerts, state
|
||||
//! whether the product is affected, and download the statements as OpenVEX
|
||||
//! or CycloneDX VEX.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use compliance_core::models::{CveAlert, VexJustification, VexStatus};
|
||||
|
||||
/// A VEX statement as the editor sends it; the agent adds who and when.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct VexStatementDto {
|
||||
pub status: VexStatus,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub justification: Option<VexJustification>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub impact_statement: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub action_statement: Option<String>,
|
||||
}
|
||||
|
||||
/// A VEX document format the agent exports.
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum VexFormat {
|
||||
OpenVex,
|
||||
CycloneDx,
|
||||
}
|
||||
|
||||
impl VexFormat {
|
||||
/// The agent's `format` query value.
|
||||
pub const fn query(self) -> &'static str {
|
||||
match self {
|
||||
Self::OpenVex => "openvex",
|
||||
Self::CycloneDx => "cyclonedx",
|
||||
}
|
||||
}
|
||||
|
||||
/// The file name a download of target `target_id` is saved as, named
|
||||
/// like the files in the evidence pack.
|
||||
pub fn filename(self, target_id: &str) -> String {
|
||||
match self {
|
||||
Self::OpenVex => format!("vex-{target_id}.openvex.json"),
|
||||
Self::CycloneDx => format!("vex-{target_id}.cdx.json"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The agent's list reply (read on the server only).
|
||||
#[cfg(feature = "server")]
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct AlertsResponse {
|
||||
data: Vec<CveAlert>,
|
||||
}
|
||||
|
||||
/// The CVE alerts of target `target_id` with their VEX statements, newest
|
||||
/// first.
|
||||
#[server]
|
||||
pub async fn fetch_target_cves(target_id: String) -> Result<Vec<CveAlert>, ServerFnError> {
|
||||
let resp = super::agent_client::agent_get(&format!("/api/v1/targets/{target_id}/cves"))
|
||||
.await?
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| ServerFnError::new(e.to_string()))?;
|
||||
let body: AlertsResponse = super::agent_client::json_or_error(resp).await?;
|
||||
Ok(body.data)
|
||||
}
|
||||
|
||||
/// State the VEX status of alert `alert_id`. The agent refuses (422) a
|
||||
/// `not_affected` without a reason and an `affected` without an action, and
|
||||
/// read-only roles (403); the refusal is the error.
|
||||
#[server]
|
||||
pub async fn save_cve_vex(
|
||||
alert_id: String,
|
||||
statement: VexStatementDto,
|
||||
) -> Result<(), ServerFnError> {
|
||||
let resp = super::agent_client::agent_request(
|
||||
reqwest::Method::PATCH,
|
||||
&format!("/api/v1/cves/{alert_id}/vex"),
|
||||
)
|
||||
.await?
|
||||
.json(&statement)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| ServerFnError::new(e.to_string()))?;
|
||||
super::agent_client::ok_or_error(resp).await
|
||||
}
|
||||
|
||||
/// The VEX document of target `target_id` in `format`, as text to save.
|
||||
#[server]
|
||||
pub async fn fetch_vex_export(
|
||||
target_id: String,
|
||||
format: VexFormat,
|
||||
) -> Result<String, ServerFnError> {
|
||||
let resp = super::agent_client::agent_get(&format!(
|
||||
"/api/v1/targets/{target_id}/vex?format={}",
|
||||
format.query()
|
||||
))
|
||||
.await?
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| ServerFnError::new(e.to_string()))?;
|
||||
super::agent_client::ok_response(resp)
|
||||
.await?
|
||||
.text()
|
||||
.await
|
||||
.map_err(|e| ServerFnError::new(e.to_string()))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn formats_name_their_query_and_file() {
|
||||
assert_eq!(VexFormat::OpenVex.query(), "openvex");
|
||||
assert_eq!(VexFormat::CycloneDx.query(), "cyclonedx");
|
||||
assert_eq!(VexFormat::CycloneDx.filename("65f0"), "vex-65f0.cdx.json");
|
||||
assert_eq!(VexFormat::OpenVex.filename("65f0"), "vex-65f0.openvex.json");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_statement_leaves_out_what_is_not_given() {
|
||||
let dto = VexStatementDto {
|
||||
status: VexStatus::NotAffected,
|
||||
justification: Some(VexJustification::VulnerableCodeNotInExecutePath),
|
||||
impact_statement: None,
|
||||
action_statement: None,
|
||||
};
|
||||
assert_eq!(
|
||||
serde_json::to_value(&dto).ok(),
|
||||
Some(serde_json::json!({
|
||||
"status": "not_affected",
|
||||
"justification": "vulnerable_code_not_in_execute_path",
|
||||
}))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -235,7 +235,7 @@ pub fn SbomPage() -> Element {
|
||||
} else {
|
||||
format!("sbom-{repo}-cyclonedx.json")
|
||||
};
|
||||
trigger_download(&json, &filename);
|
||||
crate::infrastructure::download::save_json(&json, &filename);
|
||||
}
|
||||
Err(e) => toasts.push(
|
||||
ToastType::Error,
|
||||
@@ -751,47 +751,6 @@ fn license_type_class(is_copyleft: bool) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "web")]
|
||||
fn trigger_download(content: &str, filename: &str) {
|
||||
use wasm_bindgen::JsCast;
|
||||
let Some(window) = web_sys::window() else {
|
||||
return;
|
||||
};
|
||||
let Some(document) = window.document() else {
|
||||
return;
|
||||
};
|
||||
|
||||
let blob_parts = js_sys::Array::new();
|
||||
blob_parts.push(&wasm_bindgen::JsValue::from_str(content));
|
||||
|
||||
let opts = web_sys::BlobPropertyBag::new();
|
||||
opts.set_type("application/json");
|
||||
let Ok(blob) = web_sys::Blob::new_with_str_sequence_and_options(&blob_parts, &opts) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Ok(url) = web_sys::Url::create_object_url_with_blob(&blob) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Ok(el) = document.create_element("a") else {
|
||||
return;
|
||||
};
|
||||
let Ok(a) = el.dyn_into::<web_sys::HtmlAnchorElement>() else {
|
||||
return;
|
||||
};
|
||||
a.set_href(&url);
|
||||
a.set_download(filename);
|
||||
a.click();
|
||||
|
||||
let _ = web_sys::Url::revoke_object_url(&url);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "web"))]
|
||||
fn trigger_download(_content: &str, _filename: &str) {
|
||||
// Server-side: no-op (downloads only happen in the browser)
|
||||
}
|
||||
|
||||
/// The tooltip of a KEV badge: since when, and whether ransomware uses it.
|
||||
fn kev_title(kev: &KevData, lang: Lang) -> String {
|
||||
let mut title = format!("{} {}", tx::KEV_SINCE.get(lang), kev.date_added);
|
||||
|
||||
@@ -17,6 +17,7 @@ use crate::components::scan_coverage::ScanCoverage;
|
||||
use crate::components::scan_runs::ScanRunList;
|
||||
use crate::components::severity_badge::SeverityBadge;
|
||||
use crate::components::toast::{ToastType, Toasts};
|
||||
use crate::components::vex_panel::VexPanel;
|
||||
use crate::i18n::texts::{common, kinds, targets as tx};
|
||||
use crate::i18n::use_lang;
|
||||
use crate::infrastructure::evidence::{fetch_compliance, CraCounts};
|
||||
@@ -268,6 +269,11 @@ pub fn TargetPage(id: String) -> Element {
|
||||
}
|
||||
}
|
||||
|
||||
section { class: "card target-vex",
|
||||
div { class: "target-card-head", h3 { {crate::i18n::texts::vex::TITLE.get(lang)} } }
|
||||
div { class: "target-card-body", VexPanel { target_id: id.clone() } }
|
||||
}
|
||||
|
||||
div { class: "target-columns",
|
||||
section { class: "card",
|
||||
div { class: "target-card-head", h3 { {tx::SCAN_RUNS.get(lang)} } }
|
||||
|
||||
@@ -49,6 +49,8 @@ export default withMermaid(defineConfig({
|
||||
{ text: 'Befunde', link: '/guide/findings' },
|
||||
{ text: 'Befunde aus manuellen Tests', link: '/guide/manual-findings' },
|
||||
{ text: 'Stückliste (SBOM) und Lizenzen', link: '/guide/sbom' },
|
||||
{ text: 'Schwachstellen bewerten (VEX)', link: '/guide/vex' },
|
||||
{ text: 'Assessing vulnerabilities (English)', link: '/guide/vex-en' },
|
||||
{ text: 'CRA-Anforderungen', link: '/features/control-mapping' },
|
||||
{ text: 'Daten und Aufbewahrung', link: '/guide/data-retention' },
|
||||
],
|
||||
|
||||
+3
-1
@@ -206,7 +206,9 @@ license, as CycloneDX allows.
|
||||
|
||||
For each known vulnerability (CVE alert) of a target you state whether the
|
||||
product is affected (VEX, *Vulnerability Exploitability eXchange*), as the CRA
|
||||
expects of a manufacturer handling vulnerabilities:
|
||||
expects of a manufacturer handling vulnerabilities. In the dashboard this is
|
||||
the **Schwachstellen und VEX** section of a target (see
|
||||
[Assessing vulnerabilities](./vex-en.md)). The statuses:
|
||||
|
||||
| Status | Meaning | Required |
|
||||
|---|---|---|
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
---
|
||||
title: Assessing vulnerabilities (VEX)
|
||||
---
|
||||
|
||||
# Assessing vulnerabilities (VEX)
|
||||
|
||||
For each known vulnerability (CVE) in a target's components you state whether
|
||||
your product is affected. These statements are called VEX (*Vulnerability
|
||||
Exploitability eXchange*). The CRA requires manufacturers to assess
|
||||
vulnerabilities and inform users; VEX is the usual format for it.
|
||||
|
||||
## Where
|
||||
|
||||
On a target's page, section **Vulnerabilities and VEX**. The table shows each
|
||||
vulnerability with its component, severity, status and who made the
|
||||
statement.
|
||||
|
||||
## Statuses
|
||||
|
||||
| Status | Meaning | Required |
|
||||
|---|---|---|
|
||||
| **Under investigation** | Not assessed yet; every vulnerability starts here | -- |
|
||||
| **Affected** | The product is affected | What users must do (e.g. "Update to version 2.3") |
|
||||
| **Not affected** | The product is not affected | A justification or a statement saying why |
|
||||
| **Fixed** | The product no longer contains the vulnerable component or version | -- |
|
||||
|
||||
Justifications for "Not affected":
|
||||
|
||||
- **Component not present**
|
||||
- **Vulnerable code not present**
|
||||
- **Vulnerable code not in execute path**
|
||||
- **Cannot be controlled by an adversary**
|
||||
- **Inline mitigations already exist**
|
||||
|
||||
## Assessing
|
||||
|
||||
1. Click **Assess** in the vulnerability's row.
|
||||
2. Choose a status and fill in what it requires. Until you do, **Save** stays
|
||||
disabled and a note says what is missing.
|
||||
3. **Save**. The "Stated by" column shows your name.
|
||||
|
||||
Read-only roles see the statements but cannot assess.
|
||||
|
||||
## What a scan changes
|
||||
|
||||
When a complete scan no longer finds a vulnerability (the component was
|
||||
removed or updated), it is marked fixed and "Stated by" shows **Scan**. A
|
||||
"Not affected" or "Fixed" stated by a person is never changed by a scan. If
|
||||
the vulnerability comes back, the scan withdraws its "Fixed".
|
||||
|
||||
## Downloading
|
||||
|
||||
**Download OpenVEX** and **Download CycloneDX VEX** save the target's
|
||||
statements as OpenVEX 0.2.0 and CycloneDX 1.5. Both files are also in the
|
||||
evidence pack (`vex.openvex.json`, `vex.cdx.json`). Formats, how the terms map
|
||||
and the API: see [SBOM](./sbom.md#vex-the-status-of-each-vulnerability).
|
||||
@@ -0,0 +1,59 @@
|
||||
---
|
||||
title: Schwachstellen bewerten (VEX)
|
||||
---
|
||||
|
||||
# Schwachstellen bewerten (VEX)
|
||||
|
||||
Für jede bekannte Schwachstelle (CVE) in den Komponenten eines Prüfobjekts
|
||||
halten Sie fest, ob Ihr Produkt betroffen ist. Diese Aussagen heißen VEX
|
||||
(*Vulnerability Exploitability eXchange*). Der CRA verlangt vom Hersteller,
|
||||
Schwachstellen zu bewerten und Nutzer zu informieren; VEX ist das übliche
|
||||
Format dafür.
|
||||
|
||||
## Wo
|
||||
|
||||
Auf der Seite eines Prüfobjekts, Abschnitt **Schwachstellen und VEX**. Die
|
||||
Tabelle zeigt jede Schwachstelle mit Komponente, Schweregrad, Status und wer
|
||||
die Aussage gemacht hat.
|
||||
|
||||
## Status
|
||||
|
||||
| Status | Bedeutung | Pflichtangabe |
|
||||
|---|---|---|
|
||||
| **In Prüfung** | Noch nicht bewertet; jede Schwachstelle beginnt hier | -- |
|
||||
| **Betroffen** | Das Produkt ist betroffen | Was Nutzer tun müssen (z. B. „Auf Version 2.3 aktualisieren“) |
|
||||
| **Nicht betroffen** | Das Produkt ist nicht betroffen | Eine Begründung oder ein Freitext, warum |
|
||||
| **Behoben** | Das Produkt enthält die verwundbare Komponente oder Version nicht mehr | -- |
|
||||
|
||||
Begründungen für „Nicht betroffen“:
|
||||
|
||||
- **Komponente nicht enthalten**
|
||||
- **Verwundbarer Code nicht enthalten**
|
||||
- **Verwundbarer Code wird nicht ausgeführt**
|
||||
- **Nicht durch Angreifer steuerbar**
|
||||
- **Schutzmaßnahmen bereits vorhanden**
|
||||
|
||||
## Bewerten
|
||||
|
||||
1. In der Zeile der Schwachstelle auf **Bewerten** klicken.
|
||||
2. Status wählen und die Pflichtangabe ausfüllen. Fehlt sie, bleibt
|
||||
**Speichern** gesperrt und ein Hinweis sagt, was fehlt.
|
||||
3. **Speichern**. Die Spalte „Aussage von“ zeigt Ihren Namen.
|
||||
|
||||
Rollen mit Lesezugriff sehen die Aussagen, können aber nicht bewerten.
|
||||
|
||||
## Was die Prüfung ändert
|
||||
|
||||
Findet eine vollständige Prüfung eine Schwachstelle nicht mehr (Komponente
|
||||
entfernt oder aktualisiert), wird sie als behoben markiert; „Aussage von“
|
||||
zeigt dann **Prüfung**. Eine Aussage „Nicht betroffen“ oder „Behoben“, die
|
||||
eine Person gemacht hat, ändert die Prüfung nie. Taucht die Schwachstelle
|
||||
wieder auf, nimmt die Prüfung ihr „Behoben“ zurück.
|
||||
|
||||
## Herunterladen
|
||||
|
||||
**OpenVEX herunterladen** und **CycloneDX VEX herunterladen** speichern die
|
||||
Aussagen des Prüfobjekts als OpenVEX 0.2.0 bzw. CycloneDX 1.5. Beide Dateien
|
||||
liegen auch im Nachweispaket (`vex.openvex.json`, `vex.cdx.json`). Formate,
|
||||
Zuordnung der Begriffe und API: siehe
|
||||
[Stückliste (SBOM)](./sbom.md#vex-the-status-of-each-vulnerability).
|
||||
@@ -23,7 +23,9 @@ together on stage in one pass before the next prod promotion.
|
||||
| #492 | Vendored MIT semgrep packs (GitLab, 0xdea, elttam); guard against registry rules |
|
||||
| #495 | Binary depth: PE/ELF hardening, signatures, .NET references, CPE/purl candidates, Intel HEX checks |
|
||||
| #498 (1/4) | VEX status on CVE alerts, OpenVEX and CycloneDX VEX, a valid CycloneDX SBOM |
|
||||
| #496 | SBOM quality score (sbomqs) |
|
||||
| #494 | DevSkim: .NET SAST without a build (C#, VB.NET, .config) |
|
||||
| #498 (2/4) | VEX editor and downloads on the target page |
|
||||
|
||||
**Customer-visible on the next prod rescan** is marked **[visible]**: these
|
||||
change what a customer sees on their existing targets, without them doing
|
||||
@@ -519,6 +521,31 @@ alerts (e.g. the log4j/gson target of check 19).
|
||||
Codeanalyse findings from DevSkim, and VB.NET code is now counted as a
|
||||
language (controls DevSkim checks are assessed for it).
|
||||
|
||||
### 26. #498 part 2: VEX in the dashboard
|
||||
|
||||
Use the target of check 22 (one with CVE alerts), as IT-admin and as member.
|
||||
|
||||
- **Do:** open the target. **Expect:** a card **Schwachstellen und VEX**
|
||||
between the open findings and the scan runs: each CVE with component,
|
||||
severity, status (**In Prüfung** for unassessed ones) and "Aussage von"
|
||||
(the name, or **Prüfung** for a scan's `fixed`). A target without CVEs says
|
||||
so.
|
||||
- **Do:** **Bewerten** on a CVE, choose **Nicht betroffen** without a
|
||||
justification or text, then with **Verwundbarer Code wird nicht
|
||||
ausgeführt**; choose **Betroffen** with and without "Was Nutzer tun
|
||||
müssen". **Expect:** **Speichern** is disabled with a note until the
|
||||
required field is set; after saving, a success toast, the row shows the new
|
||||
status and your name; check 22's API (`GET …/cves`) returns the same.
|
||||
- **Do:** as a read-only member. **Expect:** no **Bewerten** button.
|
||||
- **Do:** **OpenVEX herunterladen**, **CycloneDX VEX herunterladen**.
|
||||
**Expect:** `vex-<id>.openvex.json` and `vex-<id>.cdx.json`, the same
|
||||
content as check 22's API downloads.
|
||||
- **Do:** switch to English. **Expect:** "Vulnerabilities and VEX", "Assess",
|
||||
"Under investigation" etc.
|
||||
- **Docs:** `/guide/vex` (German) and `/guide/vex-en` are in the docs sidebar.
|
||||
- **[visible]** a new card on every target page; the SBOM page's export still
|
||||
downloads as before (its download helper moved).
|
||||
|
||||
## After the pass
|
||||
|
||||
- The nightly job on `main` is green with the new mobile targets.
|
||||
|
||||
Reference in new issue
Block a user