From b78b4ee2fb55b2b396f72719412490b904f4eef3 Mon Sep 17 00:00:00 2001 From: Lucas Guerra Date: Mon, 2 Nov 2026 11:32:48 -0300 Subject: [PATCH] =?UTF-8?q?feat(report):=20embed=20the=20Xex=C3=A9u=20logo?= =?UTF-8?q?=20and=20add=20a=20real=20TLP=20classification=20badge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The executive report had no logo at all (just plain "XEXÉU" text) and its "CONFIDENCIAL" badge was project-invented wording, not a real classification taxonomy. Embeds the logo as a base64 data URI (mirrors Sabiá's report.rs, so the report still renders correctly as a standalone offline HTML export) and replaces the badge with FIRST.org's actual TLP 2.0 labels/colors (TlpLevel enum, defaulting to TLP:AMBER — a vulnerability report naming real exposed hosts is sensitive by nature). Applied on both the cover and the per-page running header. Co-Authored-By: Claude Sonnet 5 --- crates/xexeu-core/src/report.rs | 119 ++++++++++++++++++++++++++++++-- 1 file changed, 113 insertions(+), 6 deletions(-) diff --git a/crates/xexeu-core/src/report.rs b/crates/xexeu-core/src/report.rs index 689cec0..ed460cd 100644 --- a/crates/xexeu-core/src/report.rs +++ b/crates/xexeu-core/src/report.rs @@ -21,10 +21,56 @@ pub struct ExecutiveReport { pub emitted_at: DateTime, /// Summary of targets and vulnerability statistics. pub scope_summary: ScopeSummary, + /// Traffic Light Protocol (FIRST.org TLP 2.0) sharing classification for + /// this document. A vulnerability report is sensitive by nature, so it + /// defaults to [`TlpLevel::Amber`] (limited disclosure to the + /// organization and need-to-know) rather than an unmarked document. + pub tlp: TlpLevel, /// Report sections. pub sections: Vec, } +/// Traffic Light Protocol sharing classification, per +/// . Controls who the document may be shared +/// with — independent of, and not a substitute for, the "authorized use" +/// notice (which is about scanning authorization, not document handling). +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +pub enum TlpLevel { + /// Not for disclosure, restricted to named recipients only. + Red, + /// Limited disclosure, restricted to the organization and need-to-know — + /// the default for a vulnerability report naming real exposed hosts. + Amber, + /// Limited disclosure, restricted to the community. + Green, + /// Disclosure is not limited. + Clear, +} + +impl TlpLevel { + /// The label printed on the cover badge, e.g. `TLP:AMBER`. + pub fn label(self) -> &'static str { + match self { + TlpLevel::Red => "TLP:RED", + TlpLevel::Amber => "TLP:AMBER", + TlpLevel::Green => "TLP:GREEN", + TlpLevel::Clear => "TLP:CLEAR", + } + } + + /// The official TLP color (FIRST.org brand colors) as a CSS hex value, + /// used for the badge's border/text so the classification is + /// recognizable at a glance, not just by the text label. + pub fn color(self) -> &'static str { + match self { + TlpLevel::Red => "#FF2B2B", + TlpLevel::Amber => "#FFC000", + TlpLevel::Green => "#33FF00", + TlpLevel::Clear => "#FFFFFF", + } + } +} + /// Aggregated metrics over the audited scope. #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct ScopeSummary { @@ -477,6 +523,7 @@ impl ExecutiveReport { ), emitted_at: now, scope_summary, + tlp: TlpLevel::Amber, sections: vec![ narrative_section, kpi_section, @@ -503,7 +550,7 @@ impl ExecutiveReport { "\n\n", ); html.push_str("\n\n\n"); // 1. Cover Page @@ -517,10 +564,17 @@ impl ExecutiveReport { html.push_str("
\n"); html.push_str("
\n"); - html.push_str("
XEXÉU
\n"); - html.push_str( - "
USO AUTORIZADO · CONFIDENCIAL
\n", - ); + html.push_str("
\"\"XEXÉU
\n"); + html.push_str("
\n"); + html.push_str(&format!( + "
{1}
\n", + self.tlp.color(), + self.tlp.label() + )); + html.push_str("
USO AUTORIZADO
\n"); + html.push_str("
\n"); html.push_str("
\n"); html.push_str( "
CIBERFAUNA · AUDITORIA CONTÍNUA DE SEGURANÇA
\n", @@ -773,6 +827,37 @@ impl ExecutiveReport { } } +/// The Xexéu logo, embedded so the report renders identically whether it's +/// viewed live from `/relatorio` or saved as a standalone offline HTML file +/// (same reasoning as `Sabiá/crates/sabia-core/src/report.rs`, which this +/// mirrors — a `src="/logo.png"` reference would 404 once the file is saved +/// outside the server's reach). +const LOGO_PNG: &[u8] = include_bytes!("../../../logo.png"); + +const B64: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +/// Encodes `bytes` as a `data:image/png;base64,...` URI. +fn logo_data_uri() -> String { + let mut out = String::with_capacity(LOGO_PNG.len().div_ceil(3) * 4 + 22); + out.push_str("data:image/png;base64,"); + for chunk in LOGO_PNG.chunks(3) { + let b0 = chunk[0]; + let b1 = chunk.get(1).copied(); + let b2 = chunk.get(2).copied(); + out.push(B64[(b0 >> 2) as usize] as char); + out.push(B64[(((b0 & 0b11) << 4) | (b1.unwrap_or(0) >> 4)) as usize] as char); + out.push(match b1 { + Some(b1) => B64[(((b1 & 0b1111) << 2) | (b2.unwrap_or(0) >> 6)) as usize] as char, + None => '=', + }); + out.push(match b2 { + Some(b2) => B64[(b2 & 0b111111) as usize] as char, + None => '=', + }); + } + out +} + fn html_escape(raw: &str) -> String { raw.replace('&', "&") .replace('<', "<") @@ -844,7 +929,7 @@ body { padding-bottom: 4mm; } @top-right { - content: "USO AUTORIZADO · CONFIDENCIAL"; + content: "XEXEU_REPORT_TLP_MARKER · USO AUTORIZADO"; font-family: var(--font-mono); font-size: 7pt; font-weight: 700; @@ -904,12 +989,34 @@ body { padding-bottom: 5mm; } .cover-brand { + display: flex; + align-items: center; + gap: 3mm; font-family: var(--font-mono); font-size: 16pt; font-weight: 800; letter-spacing: 0.18em; color: var(--accent); } +.cover-logo { + width: 9mm; + height: 9mm; + object-fit: contain; +} +.cover-badges { + display: flex; + align-items: center; + gap: 2.5mm; +} +.cover-tlp { + font-family: var(--font-mono); + font-size: 8pt; + font-weight: 800; + letter-spacing: 0.1em; + border: 1.5px solid; + padding: 2px 8px; + border-radius: 4px; +} .cover-classification { font-family: var(--font-mono); font-size: 8pt;