From e2b1a1c23bf695339ca3aad4eff7b3859ed7dbcd Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Sat, 26 Sep 2026 00:05:43 +0200 Subject: [PATCH] feat(dashboard): the platform's look, German throughout, and findings a customer can read MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prüfwerk now looks like the BreakPilot portal it is opened from: the breakpilot.com palette (indigo accent, "Nacht" dark theme), the chevron wordmark and favicon. German UI, no English left on the pilot path: severity badges, the Stückliste (SBOM) page, the list of what a target's scans check (one shared component for the wizard and the target), and the CRA status notes. Findings: - lint findings (ruff, eslint) carry repo-relative paths; the absolute per-scan work dir leaked the server layout and changed their fingerprint on every scan, so rescans re-reported them as new - the list sorts by severity (ranked, not alphabetically), names the target of each finding and shows CRA refs by id, catalog controls as a count - the detail names the target (linked to its CRA status), shows each CRA requirement's title, and masks committed secrets on screen The feature flags are read before the first render, so DAST and Pentest no longer flash as available. The onboarding wizard offers machine and device software first. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p --- Dioxus.toml | 2 +- compliance-agent/src/api/handlers/findings.rs | 49 +- compliance-agent/src/pipeline/lint/eslint.rs | 5 +- compliance-agent/src/pipeline/lint/mod.rs | 40 +- compliance-agent/src/pipeline/lint/ruff.rs | 5 +- compliance-dashboard/assets/favicon.svg | 8 +- compliance-dashboard/assets/main.css | 437 ++++++++++++------ .../src/components/app_shell.rs | 19 +- compliance-dashboard/src/components/mod.rs | 1 + .../src/components/scan_coverage.rs | 102 ++++ .../src/components/severity_badge.rs | 22 +- .../src/components/sidebar.rs | 16 +- compliance-dashboard/src/i18n/texts.rs | 340 +++++++++++--- .../src/infrastructure/findings.rs | 55 +++ compliance-dashboard/src/pages/compliance.rs | 9 +- .../src/pages/finding_detail.rs | 72 ++- compliance-dashboard/src/pages/findings.rs | 72 ++- compliance-dashboard/src/pages/onboarding.rs | 63 +-- compliance-dashboard/src/pages/sbom.rs | 13 +- compliance-dashboard/src/pages/targets.rs | 23 +- 20 files changed, 1026 insertions(+), 327 deletions(-) create mode 100644 compliance-dashboard/src/components/scan_coverage.rs diff --git a/Dioxus.toml b/Dioxus.toml index 5d7d47b..b485241 100644 --- a/Dioxus.toml +++ b/Dioxus.toml @@ -4,7 +4,7 @@ default_platform = "web" asset_dir = "assets" [web.app] -title = "Prüfwerk · Breakpilot" +title = "Prüfwerk · BreakPilot" [web.watcher] reload_html = true diff --git a/compliance-agent/src/api/handlers/findings.rs b/compliance-agent/src/api/handlers/findings.rs index 09c73af..33fbe29 100644 --- a/compliance-agent/src/api/handlers/findings.rs +++ b/compliance-agent/src/api/handlers/findings.rs @@ -53,7 +53,6 @@ pub async fn list_findings( Some("asc") => 1, _ => -1, }; - let sort_doc = doc! { sort_field: sort_dir }; let skip = filter.skip(); let total = db @@ -62,14 +61,30 @@ pub async fn list_findings( .await .unwrap_or(0); - let findings = match db - .findings() - .find(query) - .sort(sort_doc) - .skip(skip) - .limit(filter.limit) - .await - { + // Severity is stored as its name, which sorts alphabetically; rank it + // for that one sort, newest first within a severity. + let found = if sort_field == "severity" { + let pipeline = vec![ + doc! { "$match": query }, + doc! { "$addFields": { SEVERITY_RANK: severity_rank() } }, + doc! { "$sort": { SEVERITY_RANK: sort_dir, "created_at": -1 } }, + doc! { "$skip": i64::try_from(skip).unwrap_or(i64::MAX) }, + doc! { "$limit": filter.limit }, + doc! { "$project": { SEVERITY_RANK: 0 } }, + ]; + db.findings() + .aggregate(pipeline) + .with_type::() + .await + } else { + db.findings() + .find(query) + .sort(doc! { sort_field: sort_dir }) + .skip(skip) + .limit(filter.limit) + .await + }; + let findings = match found { Ok(cursor) => collect_cursor_async(cursor).await, Err(e) => { tracing::warn!("Failed to fetch findings: {e}"); @@ -84,6 +99,22 @@ pub async fn list_findings( })) } +/// The temporary field the severity sort ranks on. +const SEVERITY_RANK: &str = "_severity_rank"; + +/// A finding's severity as a number, critical highest, for sorting. +fn severity_rank() -> mongodb::bson::Document { + doc! { "$switch": { + "branches": [ + { "case": { "$eq": ["$severity", "critical"] }, "then": 4 }, + { "case": { "$eq": ["$severity", "high"] }, "then": 3 }, + { "case": { "$eq": ["$severity", "medium"] }, "then": 2 }, + { "case": { "$eq": ["$severity", "low"] }, "then": 1 }, + ], + "default": 0, + } } +} + #[tracing::instrument(skip_all, fields(finding_id = %id))] pub async fn get_finding( Extension(agent): AgentExt, diff --git a/compliance-agent/src/pipeline/lint/eslint.rs b/compliance-agent/src/pipeline/lint/eslint.rs index 03c94de..088c66f 100644 --- a/compliance-agent/src/pipeline/lint/eslint.rs +++ b/compliance-agent/src/pipeline/lint/eslint.rs @@ -35,6 +35,7 @@ pub(super) async fn run_eslint(repo_path: &Path, repo_id: &str) -> Result Severity::Medium, @@ -46,7 +47,7 @@ pub(super) async fn run_eslint(repo_path: &Path, repo_id: &str) -> Result Result bool { || repo_path.join("requirements.txt").exists() } +/// A linter's file path relative to the scanned tree. +/// +/// ruff and eslint report absolute paths, and the tree lives in a per-scan +/// work directory: kept as-is, the path would show the server's layout to the +/// customer and change every finding's fingerprint on every scan. Paths +/// outside the tree are kept unchanged. +pub(super) fn repo_relative(repo_path: &Path, file: &str) -> String { + let file_path = Path::new(file); + if let Ok(rel) = file_path.strip_prefix(repo_path) { + return rel.to_string_lossy().into_owned(); + } + // The tool may resolve symlinks (e.g. a temp dir) that `repo_path` keeps. + repo_path + .canonicalize() + .ok() + .and_then(|root| { + file_path + .strip_prefix(root) + .ok() + .map(|rel| rel.to_string_lossy().into_owned()) + }) + .unwrap_or_else(|| file.to_string()) +} + /// Run a command with a timeout, returning its output or an error pub(crate) async fn run_with_timeout( child: tokio::process::Child, @@ -118,7 +142,21 @@ pub(crate) async fn run_with_timeout( #[cfg(test)] mod tests { - use super::{has_js_project, has_rust_project, LintScanner}; + use super::{has_js_project, has_rust_project, repo_relative, LintScanner}; + + #[test] + fn linter_paths_are_relative_to_the_scanned_tree() { + let root = std::path::Path::new("/data/work/t1/a1"); + assert_eq!( + repo_relative(root, "/data/work/t1/a1/src/app.py"), + "src/app.py" + ); + assert_eq!(repo_relative(root, "src/app.py"), "src/app.py"); + assert_eq!( + repo_relative(root, "/elsewhere/app.py"), + "/elsewhere/app.py" + ); + } use compliance_core::traits::Scanner; use compliance_core::ExecPolicy; diff --git a/compliance-agent/src/pipeline/lint/ruff.rs b/compliance-agent/src/pipeline/lint/ruff.rs index d506c3c..5236d0c 100644 --- a/compliance-agent/src/pipeline/lint/ruff.rs +++ b/compliance-agent/src/pipeline/lint/ruff.rs @@ -30,6 +30,7 @@ pub(super) async fn run_ruff(repo_path: &Path, repo_id: &str) -> Result Result Result - - - B + + + diff --git a/compliance-dashboard/assets/main.css b/compliance-dashboard/assets/main.css index b360b92..f88ad1e 100644 --- a/compliance-dashboard/assets/main.css +++ b/compliance-dashboard/assets/main.css @@ -1,61 +1,66 @@ /* ═══════════════════════════════════════════════════════════════ - BREAKPILOT LEDGER — Prüfwerk dashboard - The breakpilot portal's design system: paper-white ledger with - hairline rules, one violet accent, mono machine values and a - restrained status palette. Dark ledger under data-theme="dark". + BREAKPILOT — Prüfwerk dashboard + The breakpilot.com palette the platform portal uses: cool paper + ground, ink text, hairline rules, one indigo accent, mono machine + values and a restrained status palette. Keep these values in step + with the portal (platform/portal src/app/globals.css). ═══════════════════════════════════════════════════════════════ */ -@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap'); +@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700;800&family=Geist+Mono:wght@400;500;600&display=swap'); -/* ── Design Tokens (light ledger, the default) ── */ +/* ── Design Tokens (light, the default) ── */ :root { --sidebar-width: 232px; --header-height: 48px; /* Surfaces: paper, recessed wells, panels */ - --bg-primary: oklch(0.976 0.008 300); - --bg-secondary: oklch(0.995 0.004 300); - --bg-card: oklch(0.995 0.004 300); - --bg-card-solid: oklch(0.995 0.004 300); - --bg-card-hover: oklch(0.958 0.012 300); - --bg-elevated: oklch(0.958 0.012 300); + --bg-primary: #F5F6FB; + --bg-secondary: #FFFFFF; + --bg-card: #FFFFFF; + --bg-card-solid: #FFFFFF; + --bg-card-hover: #F1F2F9; + --bg-elevated: #EDEFF7; /* Ink */ - --text-primary: oklch(0.24 0.035 295); - --text-secondary: oklch(0.45 0.026 295); - --text-tertiary: oklch(0.6 0.02 297); - --text-faint: oklch(0.72 0.015 300); + --text-primary: #14162B; + --text-secondary: #414669; + --text-tertiary: #5E6384; + --text-faint: #8C91AE; - /* The single interactive accent: breakpilot violet */ - --accent: oklch(0.52 0.23 293); - --accent-hover: oklch(0.46 0.23 293); - --accent-muted: oklch(0.52 0.23 293 / 0.10); + /* The single interactive accent: breakpilot indigo */ + --accent: #4F46E5; + --accent-hover: #4338CA; + --accent-muted: rgb(79 70 229 / 0.09); --accent-glow: none; --accent-ink: #fff; /* Hairlines */ - --border: oklch(0.905 0.011 300); - --border-bright: oklch(0.85 0.014 300); - --border-strong: oklch(0.78 0.018 300); - --border-accent: oklch(0.52 0.23 293 / 0.32); + --border: #E4E6F0; + --border-bright: #D5D8E6; + --border-strong: #BEC2D6; + --border-accent: rgb(79 70 229 / 0.30); /* Functional status, low chroma */ - --danger: oklch(0.53 0.15 27); - --danger-bg: oklch(0.53 0.15 27 / 0.10); - --warning: oklch(0.62 0.105 70); - --warning-bg: oklch(0.62 0.105 70 / 0.12); - --success: oklch(0.55 0.085 155); - --success-bg: oklch(0.55 0.085 155 / 0.10); - --info: oklch(0.5 0.07 240); - --info-bg: oklch(0.5 0.07 240 / 0.10); - --orange: oklch(0.6 0.13 45); - --orange-bg: oklch(0.6 0.13 45 / 0.10); + --danger: #B3372F; + --danger-bg: rgb(179 55 47 / 0.09); + --warning: #B5761F; + --warning-bg: rgb(181 118 31 / 0.12); + --success: #2F7A5A; + --success-bg: rgb(47 122 90 / 0.10); + --info: #2E7D8F; + --info-bg: rgb(46 125 143 / 0.10); + --orange: #C4612A; + --orange-bg: rgb(196 97 42 / 0.10); /* Severity ramp (findings) */ - --sev-critical: oklch(0.5 0.16 25); - --sev-high: oklch(0.6 0.13 45); - --sev-medium: oklch(0.64 0.1 75); - --sev-low: oklch(0.6 0.02 260); + --sev-critical: #B3372F; + --sev-high: #C4612A; + --sev-medium: #B5761F; + --sev-low: #6B7090; + + /* The wordmark's chevron: indigo, with the violet upper stroke */ + --brand-chevron: #4F46E5; + --brand-chevron-top: #7C3AED; /* Typography */ --font-display: 'Geist', system-ui, -apple-system, sans-serif; @@ -67,9 +72,9 @@ --radius: 6px; --radius-lg: 8px; - --shadow-pop: 0 1px 2px oklch(0.2 0.02 260 / 0.04), - 0 8px 24px -8px oklch(0.2 0.02 260 / 0.18), - 0 2px 8px -4px oklch(0.2 0.02 260 / 0.10); + --shadow-pop: 0 1px 2px rgb(20 22 43 / 0.05), + 0 8px 24px -8px rgb(20 22 43 / 0.16), + 0 2px 8px -4px rgb(20 22 43 / 0.08); /* Transitions */ --ease-out: cubic-bezier(0.16, 1, 0.3, 1); @@ -78,96 +83,104 @@ color-scheme: light; } -/* ── Dark ledger ── +/* ── Dark ("Nacht") ── When chosen explicitly (`data-theme="dark"`), or when the OS prefers dark and no choice was made. */ :root[data-theme="dark"] { - --bg-primary: oklch(0.195 0.028 292); - --bg-secondary: oklch(0.238 0.032 292); - --bg-card: oklch(0.238 0.032 292); - --bg-card-solid: oklch(0.238 0.032 292); - --bg-card-hover: oklch(0.232 0.032 292); - --bg-elevated: oklch(0.232 0.032 292); + --bg-primary: #0F1225; + --bg-secondary: #1A1E38; + --bg-card: #1A1E38; + --bg-card-solid: #1A1E38; + --bg-card-hover: #20254A; + --bg-elevated: #151935; - --text-primary: oklch(0.94 0.012 300); - --text-secondary: oklch(0.75 0.016 300); - --text-tertiary: oklch(0.6 0.02 300); - --text-faint: oklch(0.48 0.022 300); + --text-primary: #EEF0FA; + --text-secondary: #B9BEDC; + --text-tertiary: #8D93B8; + --text-faint: #666C92; - --accent: oklch(0.7 0.2 293); - --accent-hover: oklch(0.64 0.2 293); - --accent-muted: oklch(0.7 0.2 293 / 0.18); - --border-accent: oklch(0.7 0.2 293 / 0.42); + --accent: #8B87F6; + --accent-hover: #A5A2F8; + --accent-muted: rgb(139 135 246 / 0.16); + --accent-ink: #0F1225; + --border-accent: rgb(139 135 246 / 0.40); - --border: oklch(0.31 0.028 295); - --border-bright: oklch(0.37 0.03 295); - --border-strong: oklch(0.45 0.032 295); + --border: #2A2F52; + --border-bright: #353B62; + --border-strong: #454C77; - --danger: oklch(0.66 0.17 26); - --danger-bg: oklch(0.66 0.17 26 / 0.15); - --warning: oklch(0.76 0.13 75); - --warning-bg: oklch(0.76 0.13 75 / 0.16); - --success: oklch(0.7 0.13 158); - --success-bg: oklch(0.7 0.13 158 / 0.14); - --info: oklch(0.68 0.1 240); - --info-bg: oklch(0.68 0.1 240 / 0.14); - --orange: oklch(0.72 0.15 48); - --orange-bg: oklch(0.72 0.15 48 / 0.14); + --danger: #EE7F76; + --danger-bg: rgb(238 127 118 / 0.14); + --warning: #E0A650; + --warning-bg: rgb(224 166 80 / 0.15); + --success: #5FBF93; + --success-bg: rgb(95 191 147 / 0.14); + --info: #6CC0D2; + --info-bg: rgb(108 192 210 / 0.14); + --orange: #F09A62; + --orange-bg: rgb(240 154 98 / 0.14); - --sev-critical: oklch(0.66 0.18 26); - --sev-high: oklch(0.72 0.15 48); - --sev-medium: oklch(0.78 0.12 78); - --sev-low: oklch(0.6 0.02 264); + --sev-critical: #EE7F76; + --sev-high: #F09A62; + --sev-medium: #E0A650; + --sev-low: #8D93B8; - --shadow-pop: 0 1px 2px oklch(0 0 0 / 0.3), - 0 12px 32px -10px oklch(0 0 0 / 0.6), - 0 2px 8px -4px oklch(0 0 0 / 0.5); + --brand-chevron: #8B87F6; + --brand-chevron-top: #A78BFA; + + --shadow-pop: 0 1px 2px rgb(0 0 0 / 0.3), + 0 12px 32px -10px rgb(0 0 0 / 0.6), + 0 2px 8px -4px rgb(0 0 0 / 0.5); color-scheme: dark; } @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { - --bg-primary: oklch(0.195 0.028 292); - --bg-secondary: oklch(0.238 0.032 292); - --bg-card: oklch(0.238 0.032 292); - --bg-card-solid: oklch(0.238 0.032 292); - --bg-card-hover: oklch(0.232 0.032 292); - --bg-elevated: oklch(0.232 0.032 292); + --bg-primary: #0F1225; + --bg-secondary: #1A1E38; + --bg-card: #1A1E38; + --bg-card-solid: #1A1E38; + --bg-card-hover: #20254A; + --bg-elevated: #151935; - --text-primary: oklch(0.94 0.012 300); - --text-secondary: oklch(0.75 0.016 300); - --text-tertiary: oklch(0.6 0.02 300); - --text-faint: oklch(0.48 0.022 300); + --text-primary: #EEF0FA; + --text-secondary: #B9BEDC; + --text-tertiary: #8D93B8; + --text-faint: #666C92; - --accent: oklch(0.7 0.2 293); - --accent-hover: oklch(0.64 0.2 293); - --accent-muted: oklch(0.7 0.2 293 / 0.18); - --border-accent: oklch(0.7 0.2 293 / 0.42); + --accent: #8B87F6; + --accent-hover: #A5A2F8; + --accent-muted: rgb(139 135 246 / 0.16); + --accent-ink: #0F1225; + --border-accent: rgb(139 135 246 / 0.40); - --border: oklch(0.31 0.028 295); - --border-bright: oklch(0.37 0.03 295); - --border-strong: oklch(0.45 0.032 295); + --border: #2A2F52; + --border-bright: #353B62; + --border-strong: #454C77; - --danger: oklch(0.66 0.17 26); - --danger-bg: oklch(0.66 0.17 26 / 0.15); - --warning: oklch(0.76 0.13 75); - --warning-bg: oklch(0.76 0.13 75 / 0.16); - --success: oklch(0.7 0.13 158); - --success-bg: oklch(0.7 0.13 158 / 0.14); - --info: oklch(0.68 0.1 240); - --info-bg: oklch(0.68 0.1 240 / 0.14); - --orange: oklch(0.72 0.15 48); - --orange-bg: oklch(0.72 0.15 48 / 0.14); + --danger: #EE7F76; + --danger-bg: rgb(238 127 118 / 0.14); + --warning: #E0A650; + --warning-bg: rgb(224 166 80 / 0.15); + --success: #5FBF93; + --success-bg: rgb(95 191 147 / 0.14); + --info: #6CC0D2; + --info-bg: rgb(108 192 210 / 0.14); + --orange: #F09A62; + --orange-bg: rgb(240 154 98 / 0.14); - --sev-critical: oklch(0.66 0.18 26); - --sev-high: oklch(0.72 0.15 48); - --sev-medium: oklch(0.78 0.12 78); - --sev-low: oklch(0.6 0.02 264); + --sev-critical: #EE7F76; + --sev-high: #F09A62; + --sev-medium: #E0A650; + --sev-low: #8D93B8; - --shadow-pop: 0 1px 2px oklch(0 0 0 / 0.3), - 0 12px 32px -10px oklch(0 0 0 / 0.6), - 0 2px 8px -4px oklch(0 0 0 / 0.5); + --brand-chevron: #8B87F6; + --brand-chevron-top: #A78BFA; + + --shadow-pop: 0 1px 2px rgb(0 0 0 / 0.3), + 0 12px 32px -10px rgb(0 0 0 / 0.6), + 0 2px 8px -4px rgb(0 0 0 / 0.5); color-scheme: dark; } @@ -292,31 +305,12 @@ code { color: var(--accent); } -/* Breakpilot mark + wordmark */ -.brand-mark { - width: 26px; - height: 26px; +/* BreakPilot wordmark, as on breakpilot.com and the portal: the chevron + (indigo, violet upper stroke), "Break" in ink and "Pilot" in the accent. */ +.brand-chevron { + width: 24px; + height: 23px; flex-shrink: 0; - background: var(--text-primary); - color: var(--bg-primary); - display: grid; - place-items: center; - font-family: var(--font-mono); - font-weight: 600; - font-size: 13px; - border-radius: 5px; -} - -:root[data-theme="dark"] .brand-mark { - background: var(--accent); - color: oklch(0.16 0.01 264); -} - -@media (prefers-color-scheme: dark) { - :root:not([data-theme="light"]) .brand-mark { - background: var(--accent); - color: oklch(0.16 0.01 264); - } } .brand-text { @@ -326,15 +320,14 @@ code { } .brand-name { - font-weight: 600; - font-size: 14px; - letter-spacing: -0.02em; + font-weight: 800; + font-size: 15px; + letter-spacing: -0.025em; color: var(--text-primary); - line-height: 1.2; + line-height: 1.15; } -.brand-name::after { - content: "."; +.brand-name .bp-pilot { color: var(--accent); } @@ -4123,3 +4116,167 @@ tbody tr:last-child td { transition: none; } } + +/* ── Scan coverage (what a target's scans check) ── */ +.scan-cov { + list-style: none; + display: grid; + gap: 6px; + margin: 4px 0 0; +} + +.scan-cov-row { + display: grid; + grid-template-columns: minmax(150px, max-content) 1fr; + column-gap: 12px; + row-gap: 2px; + align-items: baseline; +} + +.scan-cov-badge { + justify-self: start; +} + +.scan-cov-purpose { + color: var(--text-secondary); +} + +.scan-cov-reason { + grid-column: 2; + color: var(--text-tertiary); + font-size: 12px; +} + +.scan-cov-off { + margin-top: 8px; + color: var(--text-tertiary); + font-size: 12px; +} + +@media (max-width: 640px) { + .scan-cov-row { + grid-template-columns: 1fr; + } + + .scan-cov-reason { + grid-column: 1; + } +} + +/* ── Findings list cells ── */ +.finding-title-cell { + min-width: 260px; +} + +.finding-title-link { + display: block; + color: var(--text-primary); + font-weight: 500; + text-decoration: none; +} + +.finding-title-link:hover { + color: var(--accent); +} + +.finding-tool { + display: block; + margin-top: 2px; + font-family: var(--font-mono); + font-size: 11px; + color: var(--text-tertiary); +} + +.finding-target { + color: var(--text-secondary); + max-width: 220px; +} + +.finding-location { + min-width: 170px; + font-family: var(--font-mono); + font-size: 12px; + color: var(--text-secondary); + overflow-wrap: anywhere; +} + +.finding-controls { + display: flex; + flex-wrap: wrap; + gap: 4px; + align-items: center; +} + +.finding-controls-more, +.finding-controls-none { + font-size: 11px; + color: var(--text-tertiary); +} + +/* ── Finding detail: the CRA refs a finding concerns ── */ +.finding-refs { + list-style: none; + display: grid; + gap: 4px; +} + +.finding-refs-catalog { + color: var(--text-tertiary); + font-size: 12px; +} + +/* ── Onboarding: what kind of product ── */ +.type-group-label { + margin: 18px 0 8px; + font-family: var(--font-mono); + font-size: 11px; + font-weight: 500; + letter-spacing: 0.06em; + text-transform: uppercase; + color: var(--text-tertiary); +} + +.type-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); + gap: 10px; +} + +.type-card { + display: flex; + flex-direction: column; + gap: 3px; + padding: 12px 14px; + text-align: left; + font: inherit; + color: var(--text-primary); + background: var(--bg-card); + border: 1px solid var(--border); + border-radius: var(--radius-lg); + cursor: pointer; + transition: border-color 0.15s var(--ease-out), background 0.15s var(--ease-out); +} + +.type-card:hover { + border-color: var(--border-strong); +} + +.type-card[aria-pressed="true"] { + border-color: var(--accent); + background: var(--accent-muted); + box-shadow: inset 0 0 0 1px var(--accent); +} + +.type-card:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; +} + +.type-card-name { + font-weight: 600; +} + +.type-card-hint { + font-size: 12px; + color: var(--text-tertiary); +} diff --git a/compliance-dashboard/src/components/app_shell.rs b/compliance-dashboard/src/components/app_shell.rs index 1340fe9..dc539c7 100644 --- a/compliance-dashboard/src/components/app_shell.rs +++ b/compliance-dashboard/src/components/app_shell.rs @@ -6,24 +6,21 @@ use crate::components::notification_bell::NotificationBell; use crate::components::sidebar::Sidebar; use crate::components::toast::{ToastContainer, Toasts}; use crate::infrastructure::auth_check::check_auth; -use crate::infrastructure::platform::{fetch_platform_info, PlatformInfo}; +use crate::infrastructure::platform::fetch_platform_info; #[component] pub fn AppShell() -> Element { use_context_provider(Toasts::new); crate::i18n::provide_lang(); - // Agent contract handshake (features such as `source_only`). Provided - // app-wide so pages can hide runtime-only surfaces; defaults to the - // full feature set until the agent answers. - let mut platform = use_context_provider(|| Signal::new(PlatformInfo::default())); - use_future(move || async move { - if let Ok(info) = fetch_platform_info().await { - platform.set(info); - } - }); - + // Agent contract handshake (features such as `source_only`), provided + // app-wide so pages can hide runtime-only surfaces. Read on the server + // before the first render, so a page never shows a feature first and + // then takes it away; an unreachable agent reads as the full set. + let platform = use_server_future(fetch_platform_info)?; let auth = use_server_future(check_auth)?; + let platform_now = platform().and_then(Result::ok).unwrap_or_default(); + use_context_provider(|| Signal::new(platform_now)); match auth() { Some(Ok(info)) if info.authenticated => { diff --git a/compliance-dashboard/src/components/mod.rs b/compliance-dashboard/src/components/mod.rs index 6896bc7..a24f5dc 100644 --- a/compliance-dashboard/src/components/mod.rs +++ b/compliance-dashboard/src/components/mod.rs @@ -12,6 +12,7 @@ pub mod notification_bell; pub mod page_header; pub mod pagination; pub mod pentest_wizard; +pub mod scan_coverage; pub mod scan_runs; pub mod severity_badge; pub mod sidebar; diff --git a/compliance-dashboard/src/components/scan_coverage.rs b/compliance-dashboard/src/components/scan_coverage.rs new file mode 100644 index 0000000..ef4bc2f --- /dev/null +++ b/compliance-dashboard/src/components/scan_coverage.rs @@ -0,0 +1,102 @@ +//! What a target's scans cover: one line per scan that belongs to the +//! target's type, in the customer's words, with the reason when one cannot +//! run. Scans switched off in this environment are folded into one line. + +use compliance_core::models::ScanType; +use dioxus::prelude::*; + +use crate::i18n::texts::{coverage, findings}; +use crate::i18n::{use_lang, Lang}; +use crate::infrastructure::platform::{is_feature_disabled_skip, stage_tone}; + +/// One row of the agent's applicable-scans list, read from its JSON. +struct ScanLine { + scan_type: Option, + raw_name: String, + blocked: Option, + status: Option, + default_on: bool, +} + +impl ScanLine { + fn parse(row: &serde_json::Value) -> Self { + let text = |key: &str| row.get(key).and_then(|v| v.as_str()).map(String::from); + let raw_name = text("scan").unwrap_or_default(); + // The agent writes the snake_case display name; serde reads the + // lowercase name without underscores. + let scan_type = + serde_json::from_value(serde_json::Value::String(raw_name.replace('_', ""))).ok(); + Self { + scan_type, + raw_name, + blocked: text("blocked_reason"), + status: text("status"), + default_on: row + .get("default_on") + .and_then(|v| v.as_bool()) + .unwrap_or(false), + } + } + + fn label(&self, lang: Lang) -> String { + self.scan_type + .as_ref() + .map(|t| findings::scan_type(t).get(lang).to_string()) + .unwrap_or_else(|| self.raw_name.clone()) + } + + fn switched_off(&self) -> bool { + is_feature_disabled_skip(self.status.as_deref(), self.blocked.as_deref()) + } +} + +/// The scans that belong to a target, as the agent's applicable-scans list +/// reports them. +#[component] +pub fn ScanCoverage(scans: Vec) -> Element { + let lang = use_lang()(); + let lines: Vec = scans.iter().map(ScanLine::parse).collect(); + let (off, shown): (Vec<&ScanLine>, Vec<&ScanLine>) = + lines.iter().partition(|line| line.switched_off()); + let off_labels = off + .iter() + .map(|line| line.label(lang)) + .collect::>() + .join(", "); + + rsx! { + ul { class: "scan-cov", + for line in shown { + { + let badge = stage_tone(line.status.as_deref(), line.blocked.as_deref(), line.default_on) + .badge_class(); + let purpose = line + .scan_type + .as_ref() + .map(|t| coverage::purpose(t).get(lang).to_string()) + .unwrap_or_default(); + let reason = line.blocked.as_deref().map(|raw| { + coverage::reason(raw) + .map(|t| t.get(lang).to_string()) + .unwrap_or_else(|| raw.to_string()) + }); + rsx! { + li { class: "scan-cov-row", + span { class: "{badge} scan-cov-badge", {line.label(lang)} } + span { class: "scan-cov-purpose", "{purpose}" } + if let Some(reason) = reason { + span { class: "scan-cov-reason", "{reason}" } + } + } + } + } + } + } + if !off_labels.is_empty() { + p { class: "scan-cov-off", + {coverage::OFF_HERE.get(lang)} + " {off_labels}" + } + } + } +} diff --git a/compliance-dashboard/src/components/severity_badge.rs b/compliance-dashboard/src/components/severity_badge.rs index 7452f24..36aac02 100644 --- a/compliance-dashboard/src/components/severity_badge.rs +++ b/compliance-dashboard/src/components/severity_badge.rs @@ -1,16 +1,24 @@ use dioxus::prelude::*; +use crate::i18n::texts::{common, findings}; +use crate::i18n::use_lang; + +/// A severity as a coloured badge, labelled in the UI language. +/// +/// `severity` is the scanner's value (`critical`, `high`, `medium`, `low`, +/// anything else reads as info); case does not matter. #[component] pub fn SeverityBadge(severity: String) -> Element { - let class = match severity.to_lowercase().as_str() { - "critical" => "badge badge-critical", - "high" => "badge badge-high", - "medium" => "badge badge-medium", - "low" => "badge badge-low", - _ => "badge badge-info", + let lang = use_lang(); + let (class, label) = match severity.to_lowercase().as_str() { + "critical" => ("badge badge-critical", common::CRITICAL), + "high" => ("badge badge-high", common::HIGH), + "medium" => ("badge badge-medium", common::MEDIUM), + "low" => ("badge badge-low", common::LOW), + _ => ("badge badge-info", findings::INFO), }; rsx! { - span { class: class, "{severity}" } + span { class: class, {label.get(lang())} } } } diff --git a/compliance-dashboard/src/components/sidebar.rs b/compliance-dashboard/src/components/sidebar.rs index 88f8c9e..9859ab4 100644 --- a/compliance-dashboard/src/components/sidebar.rs +++ b/compliance-dashboard/src/components/sidebar.rs @@ -110,10 +110,22 @@ pub fn Sidebar() -> Element { // The breakpilot brand, as the portal shows it; Prüfwerk is the // product within it. div { class: "sidebar-header", - span { class: "brand-mark", aria_hidden: "true", "B" } + svg { + class: "brand-chevron", + view_box: "8.75 2.25 46.5 45", + fill: "none", + stroke_linecap: "round", + stroke_linejoin: "round", + "aria-hidden": "true", + path { d: "M12 44 L32 20 L52 44", stroke: "var(--brand-chevron)", stroke_width: "6.5" } + path { d: "M24 13 L32 5 L40 13", stroke: "var(--brand-chevron-top)", stroke_width: "5.5" } + } if !collapsed() { div { class: "brand-text", - span { class: "brand-name", "Breakpilot" } + span { class: "brand-name", + "Break" + span { class: "bp-pilot", "Pilot" } + } span { class: "brand-sub", "Prüfwerk" } } } diff --git a/compliance-dashboard/src/i18n/texts.rs b/compliance-dashboard/src/i18n/texts.rs index 6fd75f3..e2a1a16 100644 --- a/compliance-dashboard/src/i18n/texts.rs +++ b/compliance-dashboard/src/i18n/texts.rs @@ -92,7 +92,7 @@ pub mod nav { en: "Findings", }; pub const SBOM: Text = Text { - de: "SBOM", + de: "Stückliste", en: "SBOM", }; pub const ISSUES: Text = Text { @@ -617,41 +617,14 @@ pub mod targets { pub mod kinds { use super::Text; - /// The nine target families, in the order the forms offer them. + /// The nine target families, in the order the forms offer them: machine + /// and device software first (see [`MACHINE_TYPES`]), then other software. pub const TARGET_TYPES: [(&str, Text); 9] = [ ( - "web_app", + "plc_sps", Text { - de: "Webanwendung", - en: "Web application", - }, - ), - ( - "backend_service", - Text { - de: "Backend / API", - en: "Backend / API", - }, - ), - ( - "desktop_app", - Text { - de: "Desktop-Anwendung", - en: "Desktop app", - }, - ), - ( - "android_app", - Text { - de: "Android-App", - en: "Android app", - }, - ), - ( - "ios_app", - Text { - de: "iOS-App", - en: "iOS app", + de: "SPS / PLC", + en: "PLC / SPS", }, ), ( @@ -676,14 +649,46 @@ pub mod kinds { }, ), ( - "plc_sps", + "backend_service", Text { - de: "SPS / PLC", - en: "PLC / SPS", + de: "Backend / API", + en: "Backend / API", + }, + ), + ( + "web_app", + Text { + de: "Webanwendung", + en: "Web application", + }, + ), + ( + "desktop_app", + Text { + de: "Desktop-Anwendung", + en: "Desktop app", + }, + ), + ( + "android_app", + Text { + de: "Android-App", + en: "Android app", + }, + ), + ( + "ios_app", + Text { + de: "iOS-App", + en: "iOS app", }, ), ]; + /// How many of [`TARGET_TYPES`], from the start, are machine and device + /// software; the onboarding form groups them apart. + pub const MACHINE_TYPES: usize = 4; + /// The artifact kinds, in the order the forms offer them. pub const ARTIFACT_KINDS: [(&str, Text); 8] = [ ( @@ -805,6 +810,14 @@ pub mod onboarding { de: "Name", en: "Name", }; + pub const GROUP_MACHINE: Text = Text { + de: "Maschine und Gerät", + en: "Machine and device", + }; + pub const GROUP_SOFTWARE: Text = Text { + de: "Weitere Software", + en: "Other software", + }; pub const DEMO_PROMPT: Text = Text { de: "Kein Projekt zur Hand? Beginnen Sie mit dem Demo-Satz:", en: "No target at hand? Start with the versioned demo set:", @@ -812,13 +825,29 @@ pub mod onboarding { /// One-line descriptions of the target types, in `kinds::TARGET_TYPES` order. pub const TYPE_HINTS: [Text; 9] = [ Text { - de: "Frontend + Server", - en: "Front end + server", + de: "CODESYS, PLCopen XML, Structured Text (IEC 61131-3)", + en: "CODESYS, PLCopen XML, Structured Text (IEC 61131-3)", + }, + Text { + de: "Mikrocontroller ohne Betriebssystem, z. B. STM32 mit HAL", + en: "Microcontroller without an operating system, e.g. STM32 with HAL", + }, + Text { + de: "FreeRTOS, Zephyr und andere Echtzeitbetriebssysteme", + en: "FreeRTOS, Zephyr and other real-time operating systems", + }, + Text { + de: "BSP + Image", + en: "BSP + image", }, Text { de: "REST, GraphQL, gRPC", en: "REST, GraphQL, gRPC", }, + Text { + de: "Frontend + Server", + en: "Front end + server", + }, Text { de: "Windows / macOS / Linux", en: "Windows / macOS / Linux", @@ -831,22 +860,6 @@ pub mod onboarding { de: "IPA", en: "IPA", }, - Text { - de: "Mikrocontroller, kein Betriebssystem", - en: "Microcontroller, no operating system", - }, - Text { - de: "Zephyr, FreeRTOS, …", - en: "Zephyr, FreeRTOS, ...", - }, - Text { - de: "BSP + Image", - en: "BSP + image", - }, - Text { - de: "IEC 61131-3", - en: "IEC 61131-3", - }, ]; pub const ATTACH: Text = Text { de: "Artefakte hinzufügen", @@ -1127,6 +1140,14 @@ pub mod findings { de: "Fundstelle", en: "Location", }; + pub const MORE_CONTROLS: Text = Text { + de: "weitere Kontrollen", + en: "more controls", + }; + pub const COL_TARGET: Text = Text { + de: "Prüfobjekt", + en: "Target", + }; pub const COL_CONTROLS: Text = Text { de: "CRA", en: "CRA", @@ -1175,6 +1196,14 @@ pub mod findings { de: "Regel", en: "Rule", }; + pub const CATALOG_CONTROLS: Text = Text { + de: "Kontrollen aus dem BreakPilot-Katalog", + en: "controls from the BreakPilot catalog", + }; + pub const OPEN_CRA_STATUS: Text = Text { + de: "CRA-Status des Prüfobjekts", + en: "The target's CRA status", + }; pub const CRA_REFS: Text = Text { de: "CRA-Anforderungen (Anhang I)", en: "CRA requirements (Annex I)", @@ -1272,7 +1301,7 @@ pub mod findings { pub fn scan_type(scan_type: &ScanType) -> Text { let (de, en) = match scan_type { ScanType::Sast => ("Codeanalyse (SAST)", "Code analysis (SAST)"), - ScanType::Sbom => ("SBOM", "SBOM"), + ScanType::Sbom => ("Stückliste", "SBOM"), ScanType::Cve => ("Bekannte Schwachstelle (CVE)", "Known vulnerability (CVE)"), ScanType::Gdpr => ("Datenschutz", "Privacy (GDPR)"), ScanType::OAuth => ("OAuth", "OAuth"), @@ -1345,8 +1374,12 @@ pub mod findings { pub mod sbom { use super::Text; + pub const TITLE: Text = Text { + de: "Stückliste (SBOM)", + en: "Software bill of materials (SBOM)", + }; pub const SUBTITLE: Text = Text { - de: "Stückliste der Software: Abhängigkeiten, Lizenzen und bekannte Schwachstellen", + de: "Die Komponenten Ihrer Software, ihre Lizenzen und bekannte Schwachstellen (CVE)", en: "Software bill of materials: dependencies, licenses and known vulnerabilities", }; pub const PACKAGES_TAB: Text = Text { @@ -1449,6 +1482,14 @@ pub mod sbom { de: "Die folgenden Pakete stehen unter Copyleft-Lizenzen, die Pflichten bei der Weitergabe Ihrer Software auslösen können.", en: "The following copyleft-licensed packages may impose distribution requirements on your software.", }; + pub const COMPONENT_ONE: Text = Text { + de: "Komponente", + en: "component", + }; + pub const COMPONENT_MANY: Text = Text { + de: "Komponenten", + en: "components", + }; pub const PACKAGES_COUNT: Text = Text { de: "Paket(e)", en: "package(s)", @@ -1728,8 +1769,8 @@ pub mod compliance { en: "Not checkable in code", }; pub const NOT_CODE_CHECKABLE_HINT: Text = Text { - de: "Eigenschaft des Designs oder Prozesses; wird im breakpilot-Compliance-Prozess nachgewiesen.", - en: "A design or process property; evidenced in the breakpilot compliance process.", + de: "Eigenschaft des Designs oder Prozesses; wird im BreakPilot-Compliance-Prozess nachgewiesen.", + en: "A design or process property; evidenced in the BreakPilot compliance process.", }; pub const NOT_ASSESSED_HINT: Text = Text { de: "Noch keine abgeschlossene Prüfung. Nach der ersten Prüfung steht hier das Ergebnis.", @@ -2035,3 +2076,186 @@ pub mod demo { } } } + +/// What each scan does and why it cannot run, for the applicable-scans list. +pub mod coverage { + use super::Text; + use compliance_core::models::ScanType; + + /// What a scan checks, in the customer's words. Exhaustive: a new scan + /// type needs both languages. + pub fn purpose(scan_type: &ScanType) -> Text { + let (de, en) = match scan_type { + ScanType::Sast => ( + "Prüft den Quellcode auf unsichere Muster (bei C/C++ zusätzlich mit Cppcheck)", + "Checks the source for insecure patterns (with Cppcheck as well for C/C++)", + ), + ScanType::SecretDetection => ( + "Findet Passwörter, Schlüssel und Tokens im Code", + "Finds passwords, keys and tokens in the code", + ), + ScanType::Sbom => ( + "Erstellt die Stückliste der verwendeten Komponenten", + "Lists the components the software uses", + ), + ScanType::Cve => ( + "Gleicht die Komponenten mit bekannten Schwachstellen ab", + "Matches the components against known vulnerabilities", + ), + ScanType::Lint => ("Prüft die Code-Qualität", "Checks code quality"), + ScanType::PlcControlLogic => ( + "Prüft das SPS-Programm auf sicherheitsrelevante Steuerungslogik", + "Checks the PLC program for security-relevant control logic", + ), + ScanType::FirmwareStatic => ( + "Analysiert das Firmware-Image", + "Analyses the firmware image", + ), + ScanType::Dast => ( + "Testet die laufende Weboberfläche des Geräts", + "Tests the device's running web interface", + ), + ScanType::IcsProbe => ( + "Prüft Industrieprotokolle am laufenden Gerät (z. B. Modbus/TCP)", + "Probes industrial protocols on the running device (e.g. Modbus/TCP)", + ), + ScanType::ContainerScan => ("Prüft das Container-Image", "Checks the container image"), + ScanType::MobileStatic => ("Analysiert die mobile App", "Analyses the mobile app"), + ScanType::Pentest => ("Penetrationstest", "Penetration test"), + ScanType::Graph => ("Baut den Code-Graphen", "Builds the code graph"), + ScanType::Gdpr => ("Prüft Datenschutz-Muster", "Checks privacy patterns"), + ScanType::OAuth => ("Prüft die OAuth-Konfiguration", "Checks the OAuth setup"), + ScanType::CodeReview => ("Code-Review", "Code review"), + }; + Text { de, en } + } + + pub const NEEDS_WEB_URL: Text = Text { + de: "braucht eine erreichbare Web-Adresse (http/https)", + en: "needs a reachable web address (http/https)", + }; + pub const NEEDS_CODE: Text = Text { + de: "braucht Quellcode (Git-Repository oder Archiv)", + en: "needs source code (a git repository or an archive)", + }; + pub const NEEDS_FIRMWARE: Text = Text { + de: "braucht ein Firmware-Image", + en: "needs a firmware image", + }; + pub const NEEDS_PLC: Text = Text { + de: "braucht ein SPS-Projekt", + en: "needs a PLC project", + }; + pub const NEEDS_DEVICE: Text = Text { + de: "braucht die Adresse eines laufenden Geräts", + en: "needs the address of a running device", + }; + pub const NEEDS_MOBILE: Text = Text { + de: "braucht ein App-Paket (APK, AAB oder IPA)", + en: "needs an app package (APK, AAB or IPA)", + }; + pub const NEEDS_CONTAINER: Text = Text { + de: "braucht ein Container-Image", + en: "needs a container image", + }; + pub const NEEDS_ARTIFACT: Text = Text { + de: "braucht ein weiteres Artefakt", + en: "needs another artifact", + }; + pub const IMAGE_NOT_ANALYSED: Text = Text { + de: "Firmware-Images werden noch nicht entpackt: Prüfen Sie die Firmware-Quellen \ + oder importieren Sie ein Firmwerk-Paket", + en: "firmware images are not unpacked yet: scan the firmware sources or import \ + a Firmwerk bundle", + }; + pub const CONTAINER_NOT_SCANNED: Text = Text { + de: "Container-Images werden noch nicht geprüft, nur die Quellen, aus denen sie entstehen", + en: "container images are not scanned yet, only the sources that build them", + }; + pub const MOBILE_NOT_ANALYSED: Text = Text { + de: "App-Pakete werden noch nicht analysiert", + en: "app packages are not analysed yet", + }; + pub const OFF_HERE: Text = Text { + de: "In dieser Umgebung nicht aktiviert:", + en: "Not enabled in this environment:", + }; + + /// The customer's words for why a scan cannot run, from the agent's + /// English reason. `None` for a reason this table does not know; the + /// caller then shows the raw text. + pub fn reason(raw: &str) -> Option { + let r = raw.to_ascii_lowercase(); + // Missing artifacts name the kind as `no artifact provided`; + // scans no stage runs yet explain themselves in prose. + let text = if r.contains("http(s) live url") { + NEEDS_WEB_URL + } else if r.contains("firmware_image") { + NEEDS_FIRMWARE + } else if r.contains("container_image") { + NEEDS_CONTAINER + } else if r.contains("mobile_package") { + NEEDS_MOBILE + } else if r.contains("git_repo") { + NEEDS_CODE + } else if r.contains("plc_project") { + NEEDS_PLC + } else if r.contains("live_url") { + NEEDS_DEVICE + } else if r.contains("firmware image") { + IMAGE_NOT_ANALYSED + } else if r.contains("container images") { + CONTAINER_NOT_SCANNED + } else if r.contains("mobile packages") { + MOBILE_NOT_ANALYSED + } else if r.contains("artifact") { + NEEDS_ARTIFACT + } else { + return None; + }; + Some(text) + } +} + +#[cfg(test)] +mod coverage_tests { + use super::coverage::{self, reason}; + + #[test] + fn the_agents_reasons_read_in_the_customers_words() { + // The exact strings compliance-core's scan matrix produces. + let cases = [ + ( + "no http(s) live URL — DAST needs a web endpoint", + coverage::NEEDS_WEB_URL, + ), + ( + "no firmware_image artifact provided", + coverage::NEEDS_FIRMWARE, + ), + ("no live_url artifact provided", coverage::NEEDS_DEVICE), + ("no git_repo artifact provided", coverage::NEEDS_CODE), + ( + "firmware images are not unpacked or analysed yet: scan the firmware sources, \ + or import a Firmwerk bundle for the image", + coverage::IMAGE_NOT_ANALYSED, + ), + ( + "CVE matching needs an SBOM, and none is extracted from a firmware image yet", + coverage::IMAGE_NOT_ANALYSED, + ), + ( + "container images are not scanned yet: only the sources that build them are", + coverage::CONTAINER_NOT_SCANNED, + ), + ( + "mobile packages are not analysed yet: only the app's source code is scanned", + coverage::MOBILE_NOT_ANALYSED, + ), + ]; + for (raw, want) in cases { + assert_eq!(reason(raw), Some(want), "{raw}"); + } + assert_eq!(reason("something new"), None); + } +} diff --git a/compliance-dashboard/src/infrastructure/findings.rs b/compliance-dashboard/src/infrastructure/findings.rs index 89ad536..3daea54 100644 --- a/compliance-dashboard/src/infrastructure/findings.rs +++ b/compliance-dashboard/src/infrastructure/findings.rs @@ -41,6 +41,47 @@ pub fn location(file: Option<&str>, line: Option) -> Option { }) } +/// `text` with anything that looks like a committed secret shortened to its +/// first four characters, for showing a secret finding on screen. +/// +/// A secret here is a run of at least 16 token characters holding both a +/// letter and a digit: keys, tokens and hashes, not the identifiers around +/// them (`CLIENT_SECRET`). The stored finding keeps the full value. +pub fn mask_secrets(text: &str) -> String { + fn is_token_char(c: char) -> bool { + c.is_ascii_alphanumeric() || matches!(c, '+' | '/' | '=' | '_' | '-' | '.') + } + fn mask(run: &str, out: &mut String) { + let secret_like = run.len() >= 16 + && run.chars().any(|c| c.is_ascii_digit()) + && run.chars().any(|c| c.is_ascii_alphabetic()); + if secret_like { + out.push_str(&run[..4]); + out.push_str("••••••••"); + } else { + out.push_str(run); + } + } + let mut out = String::with_capacity(text.len()); + let mut run_start = None; + for (i, c) in text.char_indices() { + match (is_token_char(c), run_start) { + (true, None) => run_start = Some(i), + (false, Some(start)) => { + mask(&text[start..i], &mut out); + run_start = None; + out.push(c); + } + (false, None) => out.push(c), + (true, Some(_)) => {} + } + } + if let Some(start) = run_start { + mask(&text[start..], &mut out); + } + out +} + /// The control-mapping column is only shown when at least one finding in the /// current view carries `control_refs`. pub fn has_control_refs(findings: &[Finding]) -> bool { @@ -155,6 +196,20 @@ pub async fn update_finding_feedback(id: String, feedback: String) -> Result<(), mod tests { use super::*; + #[test] + fn secrets_are_shortened_and_identifiers_kept() { + assert_eq!( + mask_secrets(r#"CLIENT_SECRET = "5f4dcc3b5aa765d61d8327deb882cf99e1a2b3c4""#), + r#"CLIENT_SECRET = "5f4d••••••••""# + ); + assert_eq!( + mask_secrets("token ghp_ABCdef1234567890xyzXYZ in deploy.env:4"), + "token ghp_•••••••• in deploy.env:4" + ); + assert_eq!(mask_secrets("password = admin"), "password = admin"); + assert_eq!(mask_secrets(""), ""); + } + #[test] fn a_location_reads_file_colon_line() { assert_eq!( diff --git a/compliance-dashboard/src/pages/compliance.rs b/compliance-dashboard/src/pages/compliance.rs index 8c892fa..a4b5e24 100644 --- a/compliance-dashboard/src/pages/compliance.rs +++ b/compliance-dashboard/src/pages/compliance.rs @@ -8,7 +8,7 @@ use crate::app::Route; use crate::components::page_header::PageHeader; use crate::components::stat_card::StatCard; use crate::i18n::texts::{common, compliance as tx, findings as ftx, targets as ttx}; -use crate::i18n::{use_lang, Text}; +use crate::i18n::{use_lang, Lang, Text}; use crate::infrastructure::evidence::{evidence_pack_url, fetch_compliance}; /// The label and badge of a control state, in the order the page lists them. @@ -116,7 +116,12 @@ pub fn CompliancePage(id: String) -> Element { let state = control["state"].as_str().unwrap_or_default().to_string(); let shown = state_info(&state).1; let findings = control["findings"].as_array().cloned().unwrap_or_default(); - let note = control["note"].as_str().map(String::from); + // The control map's notes are engineering prose in + // English; the German hint above says the same. + let note = control["note"] + .as_str() + .filter(|_| lang == Lang::En) + .map(String::from); let reason = tx::not_assessed_reason(&control["reason"], lang); let severity = control["severity"].as_str().unwrap_or_default().to_string(); let severity_label = tx::severity(&severity).map(|t| t.get(lang)); diff --git a/compliance-dashboard/src/pages/finding_detail.rs b/compliance-dashboard/src/pages/finding_detail.rs index 73367fb..fc8c26f 100644 --- a/compliance-dashboard/src/pages/finding_detail.rs +++ b/compliance-dashboard/src/pages/finding_detail.rs @@ -2,14 +2,15 @@ use dioxus::prelude::*; use dioxus_free_icons::icons::bs_icons::*; use dioxus_free_icons::Icon; +use crate::app::Route; use crate::components::code_snippet::CodeSnippet; use crate::components::page_header::PageHeader; use crate::components::severity_badge::SeverityBadge; use crate::i18n::texts::{common, findings as tx}; use crate::i18n::{format_time, use_lang}; -use crate::infrastructure::findings::{location, wire_name}; +use crate::infrastructure::findings::{location, mask_secrets, wire_name}; use crate::pages::findings::status_icon; -use compliance_core::models::FindingStatus; +use compliance_core::models::{FindingStatus, ScanType}; /// What happened to the last save on this page, shown next to what was saved. #[derive(Debug, Clone, PartialEq)] @@ -38,6 +39,18 @@ pub fn FindingDetailPage(id: String) -> Element { } }); + // The target's name and its CRA controls' titles, for this finding's refs. + let target_status = use_resource(move || async move { + let repo_id = finding + .read() + .as_ref() + .and_then(|f| f.as_ref()) + .map(|f| f.repo_id.clone())?; + crate::infrastructure::evidence::fetch_compliance(repo_id) + .await + .ok() + }); + let snapshot = finding.read().clone(); match snapshot { @@ -47,6 +60,33 @@ pub fn FindingDetailPage(id: String) -> Element { let finding_id_for_feedback = id.clone(); let existing_feedback = f.developer_feedback.clone().unwrap_or_default(); let where_found = location(f.file_path.as_deref(), f.line_number); + // A committed secret is shown shortened; the evidence keeps it. + let is_secret = f.scan_type == ScanType::SecretDetection; + let shown = |text: &str| { + if is_secret { + mask_secrets(text) + } else { + text.to_string() + } + }; + let status_data = target_status.read().clone().flatten(); + let target_name = status_data + .as_ref() + .and_then(|d| d["target_name"].as_str()) + .map(String::from); + let control_title = |id: &str| -> Option { + status_data.as_ref()?["controls"] + .as_array()? + .iter() + .find(|c| c["control"].as_str() == Some(id))?["title"] + .as_str() + .map(String::from) + }; + let (cra_refs, catalog_refs): (Vec, Vec) = f + .control_refs + .iter() + .cloned() + .partition(|c| c.starts_with("cra-")); rsx! { div { class: "back-nav", button { @@ -85,7 +125,7 @@ pub fn FindingDetailPage(id: String) -> Element { div { class: "card", div { class: "card-header", {tx::DESCRIPTION.get(lang)} } - p { "{f.description}" } + p { {shown(&f.description)} } } // Where it is and what it violates, even when there is no @@ -93,6 +133,14 @@ pub fn FindingDetailPage(id: String) -> Element { div { class: "card", div { class: "card-header", {tx::WHERE.get(lang)} } div { style: "display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px;", + if let Some(name) = target_name { + span { style: "opacity: 0.7;", {tx::COL_TARGET.get(lang)} } + Link { + to: Route::CompliancePage { id: f.repo_id.clone() }, + title: tx::OPEN_CRA_STATUS.get(lang), + "{name}" + } + } if let Some(place) = where_found.clone() { span { style: "opacity: 0.7;", {tx::FILE.get(lang)} } span { style: "font-family: monospace;", "{place}" } @@ -109,9 +157,19 @@ pub fn FindingDetailPage(id: String) -> Element { } if !f.control_refs.is_empty() { span { style: "opacity: 0.7;", {tx::CRA_REFS.get(lang)} } - div { style: "display: flex; gap: 4px; flex-wrap: wrap;", - for c in f.control_refs.iter() { - span { class: "badge badge-info", "{c}" } + ul { class: "finding-refs", + for c in cra_refs { + li { + span { class: "badge badge-info", "{c}" } + if let Some(title) = control_title(&c) { + span { " {title}" } + } + } + } + if !catalog_refs.is_empty() { + li { class: "finding-refs-catalog", title: "{catalog_refs.join(\", \")}", + "+{catalog_refs.len()} {tx::CATALOG_CONTROLS.get(lang)}" + } } } } @@ -135,7 +193,7 @@ pub fn FindingDetailPage(id: String) -> Element { div { class: "card", div { class: "card-header", {tx::CODE.get(lang)} } CodeSnippet { - code: code.clone(), + code: shown(code), file_path: f.file_path.clone().unwrap_or_default(), line_number: f.line_number.unwrap_or(0), } diff --git a/compliance-dashboard/src/pages/findings.rs b/compliance-dashboard/src/pages/findings.rs index 9f8054f..6b0b197 100644 --- a/compliance-dashboard/src/pages/findings.rs +++ b/compliance-dashboard/src/pages/findings.rs @@ -25,7 +25,8 @@ pub fn FindingsPage(target: String) -> Element { let mut status_filter = use_signal(String::new); let mut repo_filter = use_signal(|| target.clone()); let mut search_query = use_signal(String::new); - let mut sort_by = use_signal(|| "created_at".to_string()); + // Most severe first: what needs attention leads. + let mut sort_by = use_signal(|| "severity".to_string()); let mut sort_order = use_signal(|| "desc".to_string()); let mut selected_ids = use_signal(Vec::::new); @@ -220,6 +221,25 @@ pub fn FindingsPage(target: String) -> Element { let all_ids: Vec = resp.data.iter().filter_map(|f| f.id.as_ref().map(|id| id.to_hex())).collect(); // Only show the control-mapping column when something in view is mapped. let show_controls = has_control_refs(&resp.data); + // Across all targets, each row says which one it belongs to. + let target_names: Option> = + repo_filter().is_empty().then(|| { + repos + .read() + .as_ref() + .and_then(|r| r.as_ref()) + .map(|r| { + r.data + .iter() + .filter_map(|t| { + let id = t.get("_id")?.get("$oid")?.as_str()?.to_string(); + let name = t.get("name")?.as_str()?.to_string(); + Some((id, name)) + }) + .collect() + }) + .unwrap_or_default() + }); rsx! { div { class: "card", div { class: "table-wrapper", @@ -255,7 +275,9 @@ pub fn FindingsPage(target: String) -> Element { onclick: toggle_sort("scan_type"), "{tx::COL_TYPE.get(lang)}{sort_indicator(\"scan_type\")}" } - th { {tx::COL_SCANNER.get(lang)} } + if target_names.is_some() { + th { {tx::COL_TARGET.get(lang)} } + } th { {tx::COL_LOCATION.get(lang)} } if show_controls { th { title: tx::CONTROLS_HINT.get(lang), {tx::COL_CONTROLS.get(lang)} } @@ -298,31 +320,47 @@ pub fn FindingsPage(target: String) -> Element { } } td { SeverityBadge { severity: finding.severity.to_string() } } - td { + td { class: "finding-title-cell", Link { to: Route::FindingDetailPage { id }, - style: "color: var(--accent); text-decoration: none;", + class: "finding-title-link", "{finding.title}" } + span { class: "finding-tool", "{finding.scanner}" } } td { {tx::scan_type(&finding.scan_type).get(lang)} } - td { - Icon { icon: BsCpu, width: 14, height: 14 } - " {finding.scanner}" + if let Some(names) = &target_names { + td { class: "finding-target", + {names.get(&finding.repo_id).cloned().unwrap_or_default()} + } } - td { - style: "font-family: monospace; font-size: 12px;", - Icon { icon: BsFileEarmarkCode, width: 14, height: 14 } - " {location(finding.file_path.as_deref(), finding.line_number).unwrap_or_else(|| \"—\".to_string())}" + td { class: "finding-location", + {location(finding.file_path.as_deref(), finding.line_number).unwrap_or_else(|| "—".to_string())} } if show_controls { td { - div { style: "display: flex; gap: 4px; flex-wrap: wrap;", - for c in finding.control_refs.iter() { - span { class: "badge badge-info", title: tx::CONTROLS_HINT.get(lang), "{c}" } - } - if finding.control_refs.is_empty() { - span { style: "opacity: 0.4;", "—" } + { + // CRA Annex I refs by name; master controls + // (`mc-…`) only as a count, their detail is on + // the finding's page. + let (cra, other): (Vec<&String>, Vec<&String>) = finding + .control_refs + .iter() + .partition(|c| c.starts_with("cra-")); + rsx! { + div { class: "finding-controls", + for c in cra { + span { class: "badge badge-info", title: tx::CONTROLS_HINT.get(lang), "{c}" } + } + if !other.is_empty() { + span { class: "finding-controls-more", + "+{other.len()} {tx::MORE_CONTROLS.get(lang)}" + } + } + if finding.control_refs.is_empty() { + span { class: "finding-controls-none", "—" } + } + } } } } diff --git a/compliance-dashboard/src/pages/onboarding.rs b/compliance-dashboard/src/pages/onboarding.rs index c13e6b5..98ddb0f 100644 --- a/compliance-dashboard/src/pages/onboarding.rs +++ b/compliance-dashboard/src/pages/onboarding.rs @@ -10,6 +10,7 @@ use dioxus::prelude::*; use crate::app::Route; use crate::components::demo_targets::DemoTargetsButton; use crate::components::page_header::PageHeader; +use crate::components::scan_coverage::ScanCoverage; use crate::components::scan_runs::ScanRunList; use crate::i18n::texts::{common, kinds, onboarding as tx}; use crate::i18n::{format_bytes, use_lang}; @@ -18,7 +19,7 @@ use crate::infrastructure::onboarding::{ set_archive_password, trigger_target_scan, upload_target_artifact, validate_artifact_ref, validate_target_name, ArchivePassword, ArtifactInputDto, PasswordOutcome, UNSUPPORTED_ARCHIVE, }; -use crate::infrastructure::platform::{stage_tone, use_source_only, SourceOnlyNote}; +use crate::infrastructure::platform::{use_source_only, SourceOnlyNote}; /// Artifact kinds that only make sense with a runtime (live target / device) /// — disabled when the agent reports `source_only`. @@ -71,30 +72,6 @@ fn optin_scans(scans: &[serde_json::Value]) -> Vec<(String, String)> { .collect() } -/// One row in the applicable-scans list on the last step. -#[component] -fn ScanRow(scan: serde_json::Value) -> Element { - let text = |key: &str| scan.get(key).and_then(|v| v.as_str()).map(String::from); - let name = text("scan").unwrap_or_else(|| "?".to_string()); - let rationale = text("rationale").unwrap_or_default(); - let blocked = text("blocked_reason"); - let default_on = scan - .get("default_on") - .and_then(|v| v.as_bool()) - .unwrap_or(false); - let status = text("status"); - let badge_class = stage_tone(status.as_deref(), blocked.as_deref(), default_on).badge_class(); - rsx! { - div { style: "display: flex; gap: 8px; align-items: center; padding: 6px 0;", - span { class: "{badge_class}", "{name}" } - span { style: "opacity: 0.8;", "{rationale}" } - if let Some(b) = blocked { - span { style: "opacity: 0.6; font-style: italic;", "— {b}" } - } - } - } -} - /// Where the first scan stands on the last step. #[derive(Debug, Clone, PartialEq)] enum FirstScan { @@ -205,19 +182,25 @@ pub fn OnboardingPage() -> Element { span { {tx::DEMO_PROMPT.get(lang)} } DemoTargetsButton { secondary: true } } - div { - style: "display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 12px;", - for ((value, tlabel), hint) in kinds::TARGET_TYPES.into_iter().zip(tx::TYPE_HINTS) { - div { - class: "card", - style: if target_type() == value { - "padding: 12px; cursor: pointer; border: 2px solid var(--accent, #3b82f6);" - } else { - "padding: 12px; cursor: pointer;" - }, - onclick: move |_| target_type.set(value.to_string()), - div { style: "font-weight: 600;", {tlabel.get(lang)} } - div { style: "font-size: 0.85em; opacity: 0.7;", {hint.get(lang)} } + for (group, range) in [ + (tx::GROUP_MACHINE, 0..kinds::MACHINE_TYPES), + (tx::GROUP_SOFTWARE, kinds::MACHINE_TYPES..kinds::TARGET_TYPES.len()), + ] { + h4 { class: "type-group-label", {group.get(lang)} } + div { class: "type-grid", + for ((value, tlabel), hint) in kinds::TARGET_TYPES[range.clone()] + .iter() + .copied() + .zip(tx::TYPE_HINTS[range].iter().copied()) + { + button { + r#type: "button", + class: "type-card", + "aria-pressed": if target_type() == value { "true" } else { "false" }, + onclick: move |_| target_type.set(value.to_string()), + span { class: "type-card-name", {tlabel.get(lang)} } + span { class: "type-card-hint", {hint.get(lang)} } + } } } } @@ -536,9 +519,7 @@ pub fn OnboardingPage() -> Element { if scans().is_empty() { div { style: "opacity: 0.6;", {tx::NO_SCANS.get(lang)} } } else { - for s in scans() { - ScanRow { scan: s } - } + ScanCoverage { scans: scans() } } if source_only { div { style: "margin-top: 12px; font-size: 0.9em;", diff --git a/compliance-dashboard/src/pages/sbom.rs b/compliance-dashboard/src/pages/sbom.rs index c3aaece..b68ef75 100644 --- a/compliance-dashboard/src/pages/sbom.rs +++ b/compliance-dashboard/src/pages/sbom.rs @@ -89,7 +89,7 @@ pub fn SbomPage() -> Element { rsx! { PageHeader { - title: "SBOM", + title: tx::TITLE.get(lang), description: tx::SUBTITLE.get(lang), } @@ -250,7 +250,10 @@ pub fn SbomPage() -> Element { rsx! { if let Some(total) = resp.total { div { class: "sbom-result-count", - "{total} package(s) found" + { + let noun = if total == 1 { tx::COMPONENT_ONE } else { tx::COMPONENT_MANY }; + format!("{total} {}", noun.get(lang)) + } } } div { class: "card", @@ -301,7 +304,11 @@ pub fn SbomPage() -> Element { expanded_row.set(Some(key)); } }, - "{entry.known_vulnerabilities.len()} vuln(s) ▾" + { + let n = entry.known_vulnerabilities.len(); + // "CVE" reads the same in German and English. + if n == 1 { "1 CVE ▾".to_string() } else { format!("{n} CVEs ▾") } + } } } else { span { diff --git a/compliance-dashboard/src/pages/targets.rs b/compliance-dashboard/src/pages/targets.rs index dc9f850..4fb9aaa 100644 --- a/compliance-dashboard/src/pages/targets.rs +++ b/compliance-dashboard/src/pages/targets.rs @@ -12,6 +12,7 @@ use dioxus_free_icons::Icon; use crate::components::demo_targets::DemoTargetsButton; use crate::components::manual_findings::ManualFindingsPanel; use crate::components::page_header::PageHeader; +use crate::components::scan_coverage::ScanCoverage; use crate::components::scan_runs::{status_badge, ScanRunList}; use crate::components::toast::{ToastType, Toasts}; use crate::i18n::texts::{common, kinds, scans as scan_texts, targets as tx}; @@ -21,7 +22,7 @@ use crate::infrastructure::onboarding::{ trigger_target_scan, update_target, validate_artifact_ref, validate_target_name, ArchivePassword, ArtifactInputDto, PasswordOutcome, }; -use crate::infrastructure::platform::{stage_tone, use_source_only, SourceOnlyNote}; +use crate::infrastructure::platform::{use_source_only, SourceOnlyNote}; /// The last scan's badge class and label (with the step a running scan is /// at), or `None` before the first scan. @@ -78,25 +79,7 @@ fn TargetScans(id: String) -> Element { if rows.is_empty() { div { style: "opacity: 0.6;", {tx::NO_SCANS.get(lang)} } } - for s in rows { - { - let name = str_at(&s, "scan").to_string(); - let rationale = str_at(&s, "rationale").to_string(); - let blocked = s.get("blocked_reason").and_then(|b| b.as_str()).map(String::from); - let default_on = s.get("default_on").and_then(|b| b.as_bool()).unwrap_or(false); - let status = s.get("status").and_then(|b| b.as_str()).map(String::from); - let badge = stage_tone(status.as_deref(), blocked.as_deref(), default_on).badge_class(); - rsx! { - div { style: "display: flex; gap: 8px; align-items: center; padding: 4px 0;", - span { class: "{badge}", "{name}" } - span { style: "opacity: 0.8; font-size: 0.9em;", "{rationale}" } - if let Some(b) = blocked { - span { style: "opacity: 0.6; font-style: italic; font-size: 0.9em;", "— {b}" } - } - } - } - } - } + ScanCoverage { scans: rows } if pentest && source_only { div { style: "margin-top: 6px; opacity: 0.75; font-size: 0.85em;", {tx::PENTEST_SUPPORTED.get(lang)}