diff --git a/compliance-dashboard/src/components/vex_panel.rs b/compliance-dashboard/src/components/vex_panel.rs index 70804ea..943f194 100644 --- a/compliance-dashboard/src/components/vex_panel.rs +++ b/compliance-dashboard/src/components/vex_panel.rs @@ -372,11 +372,45 @@ fn CsafExport(target_id: String) -> Element { Icon { icon: BsDownload, width: 14, height: 14 } {tx::EXPORT_CSAF.get(lang)} } - p { class: "target-muted", {tx::CSAF_HINT.get(lang)} } + p { class: "target-muted", + {tx::CSAF_TLP.get(lang)} + " " + TlpBadge { label: CSAF_DRAFT_TLP } + ". " + {tx::CSAF_HINT.get(lang)} + } } } } +/// The TLP label of the CSAF draft, as `compliance_core::csaf_docs` writes it +/// into `document.distribution.tlp`. +const CSAF_DRAFT_TLP: &str = "AMBER"; + +/// The badge class and the sharing rule of a TLP label (TLP 1.0's WHITE is +/// TLP 2.0's CLEAR), or `None` for a label TLP does not define. +fn tlp_badge(label: &str) -> Option<(&'static str, Text)> { + match label { + "RED" => Some(("badge badge-danger", tx::TLP_RED)), + "AMBER" => Some(("badge badge-medium", tx::TLP_AMBER)), + "GREEN" => Some(("badge badge-success", tx::TLP_GREEN)), + "CLEAR" | "WHITE" => Some(("badge badge-neutral", tx::TLP_CLEAR)), + _ => None, + } +} + +/// A TLP label as a coloured badge whose tooltip says what it allows. +#[component] +fn TlpBadge(label: String) -> Element { + let lang = use_lang()(); + let badge = tlp_badge(&label); + let class = badge.map_or("badge", |(class, _)| class); + let meaning = badge.map_or("", |(_, meaning)| meaning.get(lang)); + rsx! { + span { class, title: meaning, "TLP:{label}" } + } +} + /// The statement editor for one alert, starting from its current statement. /// `on_close` gets whether a statement was saved. #[component] @@ -488,6 +522,21 @@ fn VexEditor(alert: CveAlert, on_close: EventHandler) -> Element { mod tests { use super::*; + #[test] + fn each_tlp_label_has_its_colour_and_sharing_rule() { + assert_eq!( + tlp_badge("AMBER"), + Some(("badge badge-medium", tx::TLP_AMBER)) + ); + assert_eq!(tlp_badge("RED"), Some(("badge badge-danger", tx::TLP_RED))); + assert_eq!( + tlp_badge("GREEN"), + Some(("badge badge-success", tx::TLP_GREEN)) + ); + assert_eq!(tlp_badge("WHITE"), tlp_badge("CLEAR")); + assert_eq!(tlp_badge("PURPLE"), None); + } + fn statement(status: VexStatus) -> VexStatementDto { VexStatementDto { status, diff --git a/compliance-dashboard/src/i18n/texts.rs b/compliance-dashboard/src/i18n/texts.rs index e260420..4e2f53b 100644 --- a/compliance-dashboard/src/i18n/texts.rs +++ b/compliance-dashboard/src/i18n/texts.rs @@ -2330,12 +2330,32 @@ pub mod vex { de: "Web-Adresse des Herausgebers (für CSAF)", en: "Publisher web address (for CSAF)", }; + pub const CSAF_TLP: Text = Text { + de: "Der CSAF-Entwurf ist markiert als", + en: "The CSAF draft is marked", + }; pub const CSAF_HINT: Text = Text { - de: "Der CSAF-Entwurf ist als TLP:AMBER markiert. Prüfen Sie Herausgeber und \ - Aussagen, bevor Sie ihn veröffentlichen. Ohne Web-Adresse enthält er einen \ - Platzhalter.", - en: "The CSAF draft is marked TLP:AMBER. Check the publisher and the statements \ - before you publish it. Without a web address it holds a placeholder.", + de: "Prüfen Sie Herausgeber und Aussagen, bevor Sie ihn veröffentlichen. Ohne \ + Web-Adresse enthält er einen Platzhalter.", + en: "Check the publisher and the statements before you publish it. Without a web \ + address it holds a placeholder.", + }; + // What each Traffic Light Protocol label allows (FIRST TLP 2.0). + pub const TLP_RED: Text = Text { + de: "Nur für die einzelnen Empfänger, keine Weitergabe", + en: "For the individual recipients only, no further disclosure", + }; + pub const TLP_AMBER: Text = Text { + de: "Weitergabe nur intern und an Kunden, die es wissen müssen", + en: "Share only within your organisation and with clients who need to know", + }; + pub const TLP_GREEN: Text = Text { + de: "Weitergabe innerhalb der eigenen Community, nicht öffentlich", + en: "Share within your community, not publicly", + }; + pub const TLP_CLEAR: Text = Text { + de: "Weitergabe ohne Einschränkung, öffentlich", + en: "No limit on disclosure, public", }; pub const EXPORT_FAILED: Text = Text { de: "Der VEX-Export ist fehlgeschlagen", diff --git a/docs/guide/vex-en.md b/docs/guide/vex-en.md index fefe9fc..7a2cf85 100644 --- a/docs/guide/vex-en.md +++ b/docs/guide/vex-en.md @@ -68,7 +68,10 @@ The draft remediation, "Not affected" with its justification and statement, "Under investigation" and "Fixed"; - is marked as a draft (`draft`) and **TLP:AMBER**, with the note "Draft, not - published: check publisher and statements before release."; + published: check publisher and statements before release." (shown below + the download button as an amber badge whose tooltip says what TLP:AMBER + allows: share only within your organisation and with clients who need to + know); - is tagged with the UI's language (`lang`). The publisher is your workspace. Enter your company's web address before diff --git a/docs/guide/vex.md b/docs/guide/vex.md index 3c2b2a3..8ba6141 100644 --- a/docs/guide/vex.md +++ b/docs/guide/vex.md @@ -71,7 +71,10 @@ Schwachstellen veröffentlichen. Der Entwurf Abhilfe, „Nicht betroffen“ mit Begründung und Freitext, „In Prüfung“ und „Behoben“; - ist als Entwurf (`draft`) und **TLP:AMBER** markiert und trägt den Hinweis - „Draft, not published: check publisher and statements before release.“; + „Draft, not published: check publisher and statements before release.“ + (unter dem Download-Knopf als bernsteinfarbenes Abzeichen; der Tooltip + sagt, was TLP:AMBER erlaubt: Weitergabe nur intern und an Kunden, die es + wissen müssen); - ist in der Sprache der Oberfläche ausgezeichnet (`lang`). Herausgeber ist Ihr Arbeitsbereich. Tragen Sie vor dem Herunterladen die