feat(dashboard): a machine's page, its parts, CVEs and history (#1026) #1038

Merged
sharang merged 1 commits from feat/machine-page into main 2026-11-17 12:21:07 +00:00
10 changed files with 1350 additions and 7 deletions

No files matched your search

+145
View File
@@ -8476,3 +8476,148 @@ span.repo-crumb-name {
grid-template-columns: minmax(0, 1fr);
}
}
/* ── A machine: a product project and its parts (#1026) ── */
.machine-head {
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 16px;
flex-wrap: wrap;
margin: 4px 0 12px;
}
.machine-head h2 {
margin: 0;
font-size: 22px;
font-weight: 600;
letter-spacing: -0.01em;
}
.machine-head p {
margin: 4px 0 0;
}
.machine-tabs {
margin-bottom: 16px;
}
.machine-label {
font-family: var(--font-mono);
font-size: 10px;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--text-tertiary);
}
.machine-tiles {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 12px;
margin-bottom: 16px;
}
.machine-tile {
display: flex;
flex-direction: column;
gap: 6px;
padding: 16px;
}
.machine-figure {
font-size: 26px;
font-weight: 600;
letter-spacing: -0.01em;
line-height: 1;
}
.machine-badges {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.machine-card-head {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
flex-wrap: wrap;
padding: 12px 16px;
border-bottom: 1px solid var(--border);
font-size: 12px;
}
.machine-parts {
padding: 0;
margin-bottom: 16px;
}
.machine-table {
width: 100%;
min-width: 860px;
border-collapse: collapse;
}
.machine-table td {
vertical-align: top;
}
.machine-docs {
display: flex;
flex-direction: column;
gap: 12px;
padding: 16px;
}
.machine-doc {
display: flex;
flex-direction: column;
gap: 6px;
padding: 12px 14px;
border: 1px solid var(--border);
border-radius: var(--radius-lg);
}
.machine-docs p {
margin: 0;
}
.machine-filter {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
margin: 12px 0 16px;
}
.machine-filter-on {
border-color: var(--accent);
color: var(--accent);
}
.machine-group {
padding: 0;
margin-bottom: 12px;
}
.machine-group-head {
display: flex;
flex-wrap: wrap;
gap: 10px;
align-items: center;
padding: 12px 16px;
}
.machine-group .table-wrapper {
border-top: 1px solid var(--border);
}
.machine-group-toggle {
margin-left: auto;
}
.machine-nowrap {
white-space: nowrap;
}
+4
View File
@@ -38,6 +38,10 @@ pub enum Route {
},
#[route("/targets/:id/compliance")]
CompliancePage { id: String },
// A machine (#1026): a product project and its targets; `?tab=`
// `parts` (the default), `cves` or `history`.
#[route("/projects/:id?:tab")]
MachinePage { id: String, tab: String },
#[route("/onboard")]
OnboardingPage {},
// `?target=<id>` opens the list filtered to one target; a chart of
@@ -43,7 +43,7 @@ const JUSTIFICATIONS: [VexJustification; 5] = [
VexJustification::InlineMitigationsAlreadyExist,
];
fn status_text(status: VexStatus) -> Text {
pub(crate) fn status_text(status: VexStatus) -> Text {
match status {
VexStatus::UnderInvestigation => tx::UNDER_INVESTIGATION,
VexStatus::Affected => tx::AFFECTED,
@@ -53,7 +53,7 @@ fn status_text(status: VexStatus) -> Text {
}
/// The badge class of a status: red for affected, green for settled.
fn status_class(status: VexStatus) -> &'static str {
pub(crate) fn status_class(status: VexStatus) -> &'static str {
match status {
VexStatus::UnderInvestigation => "badge badge-neutral",
VexStatus::Affected => "badge badge-danger",
@@ -125,7 +125,7 @@ fn supplier_response_words(responses: &[String], lang: Lang) -> String {
/// The short reason a supplier gives, for the table: its justification,
/// else its own words when they are short, else what it says to do.
fn supplier_gist(vex: &SupplierVex, lang: Lang) -> String {
pub(crate) fn supplier_gist(vex: &SupplierVex, lang: Lang) -> String {
/// Longer words are left for the statement's panel.
const SHORT: usize = 60;
match (&vex.justification, vex.detail.as_deref().map(str::trim)) {
@@ -170,7 +170,7 @@ fn copied_from_supplier(
/// Whether an alert is about the bought-in product itself: a supplier's own
/// advisory matches the product by its name and version, which has no purl,
/// and its components by purl (#1025).
fn is_supplier_product(alert: &CveAlert) -> bool {
pub(crate) fn is_supplier_product(alert: &CveAlert) -> bool {
alert.purl.is_none()
&& alert
.advisories
@@ -180,7 +180,7 @@ fn is_supplier_product(alert: &CveAlert) -> bool {
/// The prefix of a supplier provider's key in an advisory reference, as the
/// agent stores it (`csaf_feed::SUPPLIER_PREFIX`).
const SUPPLIER_PROVIDER_PREFIX: &str = "supplier:";
pub(crate) const SUPPLIER_PROVIDER_PREFIX: &str = "supplier:";
/// Who made an alert's statement: the person's name, "Prüfung" for a scan.
fn stated_by(alert: &CveAlert, lang: Lang) -> String {
+285
View File
@@ -7344,3 +7344,288 @@ pub mod scan_history {
}
}
}
/// A machine (#1026): a product project and the targets it is made of.
pub mod machine {
use super::Text;
use crate::i18n::Lang;
pub const KIND: Text = Text {
de: "Produkt",
en: "Product",
};
pub const LOAD_FAILED: Text = Text {
de: "Die Maschine lässt sich gerade nicht laden.",
en: "The machine cannot be loaded right now.",
};
pub const NO_PARTS: Text = Text {
de: "Diesem Projekt ist noch kein Prüfobjekt zugeordnet. Ein Prüfobjekt gehört zur \
Maschine, wenn es dem Projekt zugeordnet ist (im Prüfobjekt unter „Bearbeiten“).",
en: "No target is assigned to this project yet. A target belongs to the machine once \
it is assigned to the project (under \"Edit\" on the target).",
};
pub const TAB_PARTS: Text = Text {
de: "Bestandteile",
en: "Parts",
};
pub const TAB_CVES: Text = Text {
de: "Schwachstellen",
en: "Vulnerabilities",
};
pub const TAB_HISTORY: Text = Text {
de: "Verlauf",
en: "History",
};
/// "11 offen" on the vulnerabilities tab.
pub fn open_count(n: usize, lang: Lang) -> String {
match lang {
Lang::De => format!("{n} offen"),
Lang::En => format!("{n} open"),
}
}
/// "Maschine · 4 Bestandteile, davon 2 von Zulieferern · …".
pub fn subtitle(parts: usize, bought: usize, lang: Lang) -> String {
match lang {
Lang::De => format!(
"Maschine · {parts} Bestandteile, davon {bought} von Zulieferern · alle \
Schwachstellen, Stücklisten und Nachweise als ein Produkt"
),
Lang::En => format!(
"Machine · {parts} parts, {bought} of them from suppliers · all \
vulnerabilities, bills of materials and evidence as one product"
),
}
}
pub const OPEN_CVES: Text = Text {
de: "Offene CVEs",
en: "Open CVEs",
};
pub const UNDECIDED: Text = Text {
de: "Noch nicht bewertet",
en: "Not assessed yet",
};
/// "davon 3 mit Aussage des Lieferanten".
pub fn undecided_with_supplier(n: usize, lang: Lang) -> String {
match lang {
Lang::De => format!("davon {n} mit Aussage des Lieferanten"),
Lang::En => format!("{n} of them with a supplier statement"),
}
}
pub const COMPONENTS: Text = Text {
de: "Komponenten",
en: "Components",
};
/// "in 4 Bestandteilen, 39 mehrfach verbaut".
pub fn components_hint(parts: usize, shared: u64, lang: Lang) -> String {
match lang {
Lang::De => format!("in {parts} Bestandteilen, {shared} mehrfach verbaut"),
Lang::En => format!("in {parts} parts, {shared} used in more than one"),
}
}
pub const ADVISORIES: Text = Text {
de: "Hinweise der Zulieferer",
en: "Supplier advisories",
};
/// "gelesen von 2 Zulieferern, zuletzt vor 3 Std.".
pub fn advisories_hint(providers: usize, ago: Option<&str>, lang: Lang) -> String {
match (lang, ago) {
(Lang::De, Some(ago)) => format!("gelesen von {providers} Zulieferern, zuletzt {ago}"),
(Lang::De, None) => format!("von {providers} Zulieferern, noch nicht gelesen"),
(Lang::En, Some(ago)) => format!("read from {providers} suppliers, last {ago}"),
(Lang::En, None) => format!("from {providers} suppliers, not read yet"),
}
}
pub const PARTS: Text = Text {
de: "Bestandteile",
en: "Parts",
};
pub const PARTS_HINT: Text = Text {
de: "Ein Prüfobjekt gehört zur Maschine, wenn es dem Projekt zugeordnet ist (im \
Prüfobjekt unter „Bearbeiten“).",
en: "A target belongs to the machine once it is assigned to the project (under \
\"Edit\" on the target).",
};
pub const COL_PART: Text = Text {
de: "Bestandteil",
en: "Part",
};
pub const COL_ORIGIN: Text = Text {
de: "Herkunft",
en: "Origin",
};
pub const COL_VERSION: Text = Text {
de: "Version",
en: "Version",
};
pub const COL_OPEN: Text = Text {
de: "Offene CVEs",
en: "Open CVEs",
};
pub const COL_LAST_SCAN: Text = Text {
de: "Letzte Prüfung",
en: "Last scan",
};
pub const OPEN: Text = Text {
de: "Öffnen",
en: "Open",
};
pub const IN_HOUSE: Text = Text {
de: "Eigenentwicklung",
en: "In-house",
};
pub const SUPPLIER: Text = Text {
de: "Zulieferer",
en: "Supplier",
};
pub const NONE_OPEN: Text = Text {
de: "keine",
en: "none",
};
pub const NOT_SCANNED: Text = Text {
de: "noch nicht",
en: "not yet",
};
pub const DOCUMENTS: Text = Text {
de: "Dokumente der Maschine",
en: "The machine's documents",
};
pub const DOCUMENTS_HINT: Text = Text {
de: "Für die ganze Maschine statt je Prüfobjekt: was der Hersteller nach dem CRA für \
das Produkt vorlegt.",
en: "For the whole machine rather than per target: what the manufacturer presents \
for the product under the CRA.",
};
pub const SBOM: Text = Text {
de: "Stückliste (SBOM)",
en: "Bill of materials (SBOM)",
};
pub const SBOM_HINT: Text = Text {
de: "Die Maschine mit ihren Bestandteilen, jeder mit seinem Zulieferer, und deren \
Komponenten. CycloneDX 1.6.",
en: "The machine with its parts, each with its supplier, and their components. \
CycloneDX 1.6.",
};
pub const SBOM_DOWNLOAD: Text = Text {
de: "Maschinen-SBOM herunterladen",
en: "Download the machine SBOM",
};
pub const DOWNLOAD_FAILED: Text = Text {
de: "Herunterladen fehlgeschlagen",
en: "Download failed",
};
pub const MORE_DOCUMENTS: Text = Text {
de: "VEX, CSAF und das Nachweispaket der Maschine folgen; bis dahin liegen sie je \
Bestandteil vor.",
en: "The machine's VEX, CSAF and evidence pack follow; until then each part has its \
own.",
};
pub const CVES_HINT: Text = Text {
de: "Die offenen Schwachstellen der ganzen Maschine, nach Komponente. Steckt eine \
Komponente in mehreren Bestandteilen, steht sie einmal da, mit jedem Bestandteil \
darunter: Ob sie betrifft, bewerten Sie je Bestandteil, denn im einen kann der \
Code erreichbar sein, im anderen nicht.",
en: "The open vulnerabilities of the whole machine, by component. A component in \
several parts is listed once, with each part beneath it: whether it affects is \
assessed per part, as the code may be reached in one and not in another.",
};
pub const FILTER_ALL: Text = Text {
de: "Alle",
en: "All",
};
pub const NO_CVES: Text = Text {
de: "Keine offenen Schwachstellen.",
en: "No open vulnerabilities.",
};
/// "2 CVEs · in 2 Bestandteilen".
pub fn group_meta(cves: usize, parts: usize, lang: Lang) -> String {
let count = if cves == 1 {
"1 CVE".to_string()
} else {
format!("{cves} CVEs")
};
match (lang, parts) {
(_, 1) => count,
(Lang::De, p) => format!("{count} · in {p} Bestandteilen"),
(Lang::En, p) => format!("{count} · in {p} parts"),
}
}
/// "Update auf 4.17.21 behebt sie".
pub fn fixed_by(version: &str, lang: Lang) -> String {
match lang {
Lang::De => format!("Update auf {version} behebt sie"),
Lang::En => format!("updating to {version} fixes them"),
}
}
/// "3 Einträge zeigen".
pub fn show_rows(n: usize, lang: Lang) -> String {
match lang {
Lang::De => format!("{n} Einträge zeigen"),
Lang::En => format!("Show {n} entries"),
}
}
pub const HIDE_ROWS: Text = Text {
de: "Einträge ausblenden",
en: "Hide entries",
};
pub const ASSESS_IN_PART: Text = Text {
de: "Im Bestandteil bewerten",
en: "Assess in the part",
};
pub const CVES_FOOTNOTE: Text = Text {
de: "„—“: der Lieferant sagt nichts dazu, oder der Bestandteil ist eine \
Eigenentwicklung. Bewertet wird im Bestandteil.",
en: "\"—\": the supplier says nothing about it, or the part is made in-house. It is \
assessed in the part.",
};
pub const HISTORY_HINT: Text = Text {
de: "Was sich an der Maschine geändert hat: jede Prüfung eines Bestandteils, mit den \
Schwachstellen, die sie dazubrachte oder entfernte, und jeder neuen Version eines \
Zulieferers. Die Einzelheiten stehen im Verlauf des Bestandteils.",
en: "What changed in the machine: each scan of a part, with the vulnerabilities it \
brought or removed, and each new version from a supplier. The details are in the \
part's history.",
};
pub const NO_HISTORY: Text = Text {
de: "Noch keine Prüfung.",
en: "No scan yet.",
};
pub const COL_WHEN: Text = Text {
de: "Wann",
en: "When",
};
pub const COL_WHAT: Text = Text {
de: "Was",
en: "What",
};
pub const COL_NEW: Text = Text {
de: "CVEs neu",
en: "New CVEs",
};
pub const COL_GONE: Text = Text {
de: "CVEs weg",
en: "CVEs gone",
};
pub const IN_PART: Text = Text {
de: "Im Bestandteil",
en: "In the part",
};
pub const SCAN: Text = Text {
de: "Prüfung",
en: "Scan",
};
pub const BASELINE: Text = Text {
de: "die erste: legt den Stand fest",
en: "the first: sets the baseline",
};
pub const NEW_VERSION: Text = Text {
de: "Neue Version des Zulieferers",
en: "New version from the supplier",
};
/// "+4, −2 Komponenten".
pub fn component_moves(added: usize, removed: usize, lang: Lang) -> String {
match lang {
Lang::De => format!("Komponenten +{added}, −{removed}"),
Lang::En => format!("components +{added}, −{removed}"),
}
}
}
@@ -0,0 +1,120 @@
//! A machine (#1026): a product project and the targets it is made of,
//! read from the agent's `/api/v1/projects/{id}/…` endpoints.
use chrono::{DateTime, Utc};
use compliance_core::cve_groups::{CveGroup, SeverityCounts};
use compliance_core::models::CveAlert;
use compliance_core::scan_changes::ScanChange;
use dioxus::prelude::*;
use serde::{Deserialize, Serialize};
use super::onboarding::SupplierDto;
/// One part of a machine, as its overview lists it.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PartDto {
/// The target's id.
pub id: String,
pub name: String,
/// The target type's wire name (`firmware_rtos`).
pub target_type: String,
/// Its supplier, for a component bought in.
#[serde(default)]
pub supplier: Option<SupplierDto>,
/// Its open CVEs per severity.
pub open: SeverityCounts,
/// When it was last scanned.
#[serde(default)]
pub last_scan_at: Option<DateTime<Utc>>,
}
/// The advisories of a machine's suppliers.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MachineAdvisoriesDto {
pub advisories: u64,
pub providers: usize,
#[serde(default)]
pub checked_at: Option<DateTime<Utc>>,
}
/// A machine at a glance (`GET /api/v1/projects/{id}/overview`).
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MachineOverviewDto {
pub name: String,
pub parts: Vec<PartDto>,
pub open: SeverityCounts,
pub undecided: usize,
pub undecided_with_supplier: usize,
pub components: u64,
pub shared_components: u64,
#[serde(default)]
pub advisories: Option<MachineAdvisoriesDto>,
}
impl MachineOverviewDto {
/// The part with target id `id`.
pub fn part(&self, id: &str) -> Option<&PartDto> {
self.parts.iter().find(|p| p.id == id)
}
}
/// A machine's open CVEs (`GET /api/v1/projects/{id}/cves`).
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MachineCvesDto {
pub groups: Vec<CveGroup>,
pub alerts: Vec<CveAlert>,
}
/// One scan of one of a machine's parts.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MachineChangeDto {
/// The part (its target's id).
pub part: String,
#[serde(flatten)]
pub change: ScanChange,
}
/// The `data` of an agent answer at `path`.
#[cfg(feature = "server")]
async fn data<T: serde::de::DeserializeOwned>(path: &str) -> Result<T, ServerFnError> {
#[derive(Deserialize)]
struct Body<T> {
data: T,
}
let resp = super::agent_client::agent_get(path)
.await?
.send()
.await
.map_err(|e| ServerFnError::new(e.to_string()))?;
let body: Body<T> = super::agent_client::json_or_error(resp).await?;
Ok(body.data)
}
/// Machine `id` at a glance.
#[server]
pub async fn fetch_machine_overview(id: String) -> Result<MachineOverviewDto, ServerFnError> {
data(&format!("/api/v1/projects/{id}/overview")).await
}
/// Machine `id`'s open CVEs, grouped by component across its parts.
#[server]
pub async fn fetch_machine_cves(id: String) -> Result<MachineCvesDto, ServerFnError> {
data(&format!("/api/v1/projects/{id}/cves")).await
}
/// Machine `id`'s history: its parts' last scans, newest first.
#[server]
pub async fn fetch_machine_changes(id: String) -> Result<Vec<MachineChangeDto>, ServerFnError> {
data(&format!("/api/v1/projects/{id}/scan-changes")).await
}
/// Machine `id`'s SBOM, a CycloneDX document to save.
#[server]
pub async fn fetch_machine_sbom(id: String) -> Result<serde_json::Value, ServerFnError> {
let resp = super::agent_client::agent_get(&format!("/api/v1/projects/{id}/sbom"))
.await?
.send()
.await
.map_err(|e| ServerFnError::new(e.to_string()))?;
super::agent_client::json_or_error(resp).await
}
@@ -14,6 +14,7 @@ pub mod graph;
pub mod help_chat;
pub mod inbox;
pub mod issues;
pub mod machine;
pub mod manual_findings;
pub mod mcp;
pub mod mcp_tokens;
+767
View File
@@ -0,0 +1,767 @@
//! A machine (#1026): a product project made of in-house targets and
//! components bought in from suppliers. Three tabs: its parts with its
//! documents, its open CVEs by component across the parts, and its history.
use std::collections::{BTreeSet, HashMap};
use dioxus::prelude::*;
use compliance_core::cve_groups::{CveGroup, CveSeverity, SeverityCounts};
use compliance_core::models::CveAlert;
use compliance_core::scan_changes::ComponentRowKind;
use compliance_core::vex_docs::status_of;
use crate::app::Route;
use crate::components::severity_badge::SeverityBadge;
use crate::components::toast::{ToastType, Toasts};
use crate::components::vex_panel::{
is_supplier_product, status_class, status_text, supplier_gist, SUPPLIER_PROVIDER_PREFIX,
};
use crate::i18n::texts::{common, cve_matrix, kinds, machine as tx, repo_views as rv};
use crate::i18n::{format_ago, format_count, format_time, use_lang, Lang};
use crate::infrastructure::machine::{
fetch_machine_changes, fetch_machine_cves, fetch_machine_overview, fetch_machine_sbom,
MachineChangeDto, MachineOverviewDto, PartDto,
};
use crate::pages::target_views::RepoView;
/// A tab of the machine page.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum Tab {
Parts,
Cves,
History,
}
impl Tab {
const ALL: [Self; 3] = [Self::Parts, Self::Cves, Self::History];
/// Its name in the URL (`?tab=`).
const fn slug(self) -> &'static str {
match self {
Self::Parts => "parts",
Self::Cves => "cves",
Self::History => "history",
}
}
/// The tab named `slug`; anything else opens the parts.
fn from_slug(slug: &str) -> Self {
Self::ALL
.into_iter()
.find(|t| t.slug() == slug)
.unwrap_or(Self::Parts)
}
}
/// Which parts the CVE tab shows.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum Origin {
All,
InHouse,
Bought,
}
/// The count badges of `counts`, most severe first, the empty ones left out.
fn count_badges(counts: &SeverityCounts, lang: Lang) -> Vec<(&'static str, String)> {
counts
.by_severity()
.into_iter()
.filter(|(_, n)| *n > 0)
.map(|(severity, n)| {
(
severity_class(severity),
format!(
"{n} {}",
cve_matrix::severity(matrix_row(severity)).get(lang)
),
)
})
.collect()
}
/// The CVE grid's row of `severity`, for its lower-case label ("kritisch").
const fn matrix_row(severity: CveSeverity) -> compliance_core::cve_matrix::CveSeverity {
use compliance_core::cve_matrix::CveSeverity as Row;
match severity {
CveSeverity::Critical => Row::Critical,
CveSeverity::High => Row::High,
CveSeverity::Medium => Row::Medium,
CveSeverity::Low => Row::Low,
CveSeverity::Info => Row::Unknown,
}
}
/// The badge class of `severity`.
const fn severity_class(severity: CveSeverity) -> &'static str {
match severity {
CveSeverity::Critical => "badge badge-critical",
CveSeverity::High => "badge badge-high",
CveSeverity::Medium => "badge badge-medium",
CveSeverity::Low => "badge badge-low",
CveSeverity::Info => "badge badge-info",
}
}
/// The total of `counts`.
fn total(counts: &SeverityCounts) -> usize {
counts.by_severity().iter().map(|(_, n)| n).sum()
}
/// A part's origin as a badge and the supplier's name beside it.
#[component]
fn OriginBadge(part: PartDto, #[props(default)] with_name: bool) -> Element {
let lang = use_lang()();
rsx! {
match part.supplier {
Some(s) => rsx! {
span { class: "badge badge-accent", {tx::SUPPLIER.get(lang)} }
if with_name {
" "
span { class: "target-muted", "{s.name}" }
}
},
None => rsx! { span { class: "badge badge-neutral", {tx::IN_HOUSE.get(lang)} } },
}
}
}
/// The machine `id`'s page, on tab `tab` (`parts`, `cves`, `history`).
#[component]
pub fn MachinePage(id: String, tab: String) -> Element {
let lang = use_lang()();
let tab = Tab::from_slug(&tab);
let machine_id = use_signal(|| id.clone());
let overview = use_resource(move || async move { fetch_machine_overview(machine_id()).await });
let read = overview.read();
let data = match &*read {
None => return rsx! { div { class: "loading", {common::LOADING.get(lang)} } },
Some(Err(_)) => {
return rsx! { div { class: "card", p { class: "target-muted", {tx::LOAD_FAILED.get(lang)} } } }
}
Some(Ok(data)) => data.clone(),
};
let bought = data.parts.iter().filter(|p| p.supplier.is_some()).count();
let open = total(&data.open);
rsx! {
nav { class: "repo-crumbs", "aria-label": rv::BREADCRUMB.get(lang),
Link { to: Route::OverviewPage {}, {rv::OVERVIEW.get(lang)} }
span { class: "repo-crumb-sep", "aria-hidden": "true", "›" }
span { class: "repo-crumb-name", "aria-current": "page", "{data.name}" }
}
header { class: "machine-head",
div {
h2 { "{data.name}" }
p { class: "target-muted", {tx::subtitle(data.parts.len(), bought, lang)} }
}
span { class: "badge badge-accent", {tx::KIND.get(lang)} }
}
nav { class: "sbom-tab-bar machine-tabs", "aria-label": "{tx::TAB_PARTS.get(lang)}",
for t in Tab::ALL {
Link {
to: Route::MachinePage { id: id.clone(), tab: t.slug().to_string() },
class: if t == tab { "sbom-tab active" } else { "sbom-tab" },
"aria-current": if t == tab { "page" } else { "false" },
match t {
Tab::Parts => rsx! { {tx::TAB_PARTS.get(lang)} },
Tab::Cves => rsx! {
{tx::TAB_CVES.get(lang)}
" "
span { class: "target-muted", {tx::open_count(open, lang)} }
},
Tab::History => rsx! { {tx::TAB_HISTORY.get(lang)} },
}
}
}
}
if data.parts.is_empty() {
div { class: "card", p { class: "target-muted", {tx::NO_PARTS.get(lang)} } }
} else {
match tab {
Tab::Parts => rsx! { PartsTab { id: id.clone(), data: data.clone() } },
Tab::Cves => rsx! { CvesTab { id: id.clone(), data: data.clone() } },
Tab::History => rsx! { HistoryTab { id: id.clone(), data: data.clone() } },
}
}
}
}
/// The machine's figures, its parts and its documents.
#[component]
fn PartsTab(id: String, data: MachineOverviewDto) -> Element {
let lang = use_lang()();
let now = chrono::Utc::now();
rsx! {
div { class: "machine-tiles",
section { class: "card machine-tile",
span { class: "machine-label", {tx::OPEN_CVES.get(lang)} }
span { class: "machine-figure", "{total(&data.open)}" }
span { class: "machine-badges",
for (class, text) in count_badges(&data.open, lang) {
span { class, "{text}" }
}
}
}
section { class: "card machine-tile",
span { class: "machine-label", {tx::UNDECIDED.get(lang)} }
span { class: "machine-figure", "{data.undecided}" }
span { class: "target-muted", {tx::undecided_with_supplier(data.undecided_with_supplier, lang)} }
}
section { class: "card machine-tile",
span { class: "machine-label", {tx::COMPONENTS.get(lang)} }
span { class: "machine-figure", {format_count(data.components, lang)} }
span { class: "target-muted", {tx::components_hint(data.parts.len(), data.shared_components, lang)} }
}
if let Some(adv) = data.advisories.clone() {
section { class: "card machine-tile",
span { class: "machine-label", {tx::ADVISORIES.get(lang)} }
span { class: "machine-figure", {format_count(adv.advisories, lang)} }
span { class: "target-muted",
{tx::advisories_hint(adv.providers, adv.checked_at.map(|t| format_ago(&t, &now, lang)).as_deref(), lang)}
}
}
}
}
section { class: "card machine-parts",
div { class: "machine-card-head",
strong { {tx::PARTS.get(lang)} }
span { class: "target-muted", {tx::PARTS_HINT.get(lang)} }
}
div { class: "table-wrapper",
table { class: "machine-table",
thead {
tr {
th { {tx::COL_PART.get(lang)} }
th { {tx::COL_ORIGIN.get(lang)} }
th { {tx::COL_VERSION.get(lang)} }
th { {tx::COL_OPEN.get(lang)} }
th { {tx::COL_LAST_SCAN.get(lang)} }
th { span { class: "sr-only", {tx::OPEN.get(lang)} } }
}
}
tbody {
for part in data.parts.iter() {
tr { key: "{part.id}",
td {
strong { "{part.name}" }
div { class: "target-muted", {kinds::target_type(&part.target_type, lang)} }
}
td { OriginBadge { part: part.clone(), with_name: true } }
td {
match part.supplier.as_ref().map(|s| (s.product.clone(), s.version.clone())) {
Some((Some(product), Some(version))) => rsx! { "{product} {version}" },
Some((None, Some(version))) => rsx! { "{version}" },
_ => rsx! { span { class: "target-muted", "—" } },
}
}
td {
span { class: "machine-badges",
for (class, text) in count_badges(&part.open, lang) {
span { class, "{text}" }
}
if total(&part.open) == 0 {
span { class: "target-muted", {tx::NONE_OPEN.get(lang)} }
}
}
}
td { class: "target-muted",
match part.last_scan_at {
Some(at) => format_ago(&at, &now, lang),
None => tx::NOT_SCANNED.get(lang).to_string(),
}
}
td {
Link { to: Route::TargetPage { id: part.id.clone() }, {tx::OPEN.get(lang)} }
}
}
}
}
}
}
}
MachineDocuments { id }
}
}
/// The machine's documents: its SBOM now; VEX, CSAF and the evidence pack
/// follow (#1015).
#[component]
fn MachineDocuments(id: String) -> Element {
let lang = use_lang()();
let mut toasts = use_context::<Toasts>();
let mut busy = use_signal(|| false);
rsx! {
section { class: "card machine-docs",
div {
strong { {tx::DOCUMENTS.get(lang)} }
div { class: "target-muted", {tx::DOCUMENTS_HINT.get(lang)} }
}
div { class: "machine-doc",
span { class: "machine-label", {tx::SBOM.get(lang)} }
span { {tx::SBOM_HINT.get(lang)} }
div {
button {
class: "btn btn-secondary",
disabled: busy(),
onclick: move |_| {
let id = id.clone();
busy.set(true);
spawn(async move {
match fetch_machine_sbom(id.clone()).await {
Ok(doc) => crate::infrastructure::download::save_json(
&serde_json::to_string_pretty(&doc).unwrap_or_default(),
&format!("sbom-machine-{id}-cyclonedx.json"),
),
Err(e) => toasts.push(ToastType::Error, format!("{}: {e}", tx::DOWNLOAD_FAILED.get(lang))),
}
busy.set(false);
});
},
{tx::SBOM_DOWNLOAD.get(lang)}
}
}
}
p { class: "target-muted", {tx::MORE_DOCUMENTS.get(lang)} }
}
}
}
/// How many groups open with their rows shown; the rest open on demand.
const GROUPS_OPEN: usize = 2;
/// The machine's open CVEs by component, each with the parts it is in.
#[component]
fn CvesTab(id: String, data: MachineOverviewDto) -> Element {
let lang = use_lang()();
let machine_id = use_signal(|| id.clone());
let cves = use_resource(move || async move { fetch_machine_cves(machine_id()).await });
let mut origin = use_signal(|| Origin::All);
let parts: HashMap<String, PartDto> = data
.parts
.iter()
.map(|p| (p.id.clone(), p.clone()))
.collect();
let read = cves.read();
let Some(result) = &*read else {
return rsx! { div { class: "loading", {common::LOADING.get(lang)} } };
};
let Ok(found) = result else {
return rsx! { p { class: "target-muted", {tx::LOAD_FAILED.get(lang)} } };
};
let shows = |alert: &CveAlert| {
let bought = parts
.get(&alert.repo_id)
.is_some_and(|p| p.supplier.is_some());
match origin() {
Origin::All => true,
Origin::InHouse => !bought,
Origin::Bought => bought,
}
};
let by_id: HashMap<String, &CveAlert> = found
.alerts
.iter()
.filter_map(|a| a.id.map(|o| (o.to_hex(), a)))
.collect();
let groups: Vec<(CveGroup, Vec<CveAlert>)> = found
.groups
.iter()
.map(|g| {
let rows: Vec<CveAlert> = g
.alert_ids
.iter()
.filter_map(|id| by_id.get(id).copied())
.filter(|a| shows(a))
.cloned()
.collect();
(g.clone(), rows)
})
.filter(|(_, rows)| !rows.is_empty())
.collect();
rsx! {
p { class: "target-muted", {tx::CVES_HINT.get(lang)} }
div { class: "machine-filter",
span { class: "machine-label", {tx::PARTS.get(lang)} }
for (value, label) in [
(Origin::All, tx::FILTER_ALL),
(Origin::InHouse, tx::IN_HOUSE),
(Origin::Bought, tx::SUPPLIER),
] {
button {
r#type: "button",
class: if origin() == value { "btn btn-sm machine-filter-on" } else { "btn btn-sm" },
"aria-pressed": if origin() == value { "true" } else { "false" },
onclick: move |_| origin.set(value),
{label.get(lang)}
}
}
}
if groups.is_empty() {
p { class: "target-muted", {tx::NO_CVES.get(lang)} }
}
for (i, (group, rows)) in groups.into_iter().enumerate() {
MachineCveGroup {
key: "{group.key.package}@{group.key.version}@{group.key.purl.clone().unwrap_or_default()}",
group,
rows,
parts: parts.clone(),
open: i < GROUPS_OPEN,
}
}
p { class: "target-muted vex-footnote", {tx::CVES_FOOTNOTE.get(lang)} }
}
}
/// One component's open CVEs across the machine's parts.
#[component]
fn MachineCveGroup(
group: CveGroup,
rows: Vec<CveAlert>,
parts: HashMap<String, PartDto>,
open: bool,
) -> Element {
let lang = use_lang()();
let mut expanded = use_signal(|| open);
let in_parts = rows
.iter()
.map(|a| a.repo_id.as_str())
.collect::<BTreeSet<_>>()
.len();
let product = rows.iter().any(is_supplier_product);
rsx! {
section { class: "card machine-group",
div { class: "machine-group-head",
SeverityBadge { severity: group.counts.max().as_str().to_string() }
strong { "{group.key.package} {group.key.version}" }
span { class: "target-muted",
{tx::group_meta(group.cve_ids.len(), in_parts, lang)}
if let Some(fix) = &group.fix_version {
" · {tx::fixed_by(fix, lang)}"
}
}
if product {
span { class: "badge badge-accent", {crate::i18n::texts::vex::SUPPLIER_PRODUCT.get(lang)} }
}
if !open || !expanded() {
button {
r#type: "button",
class: "btn btn-ghost btn-sm machine-group-toggle",
"aria-expanded": if expanded() { "true" } else { "false" },
onclick: move |_| expanded.toggle(),
if expanded() { {tx::HIDE_ROWS.get(lang)} } else { {tx::show_rows(rows.len(), lang)} }
}
}
}
if expanded() {
div { class: "table-wrapper",
table { class: "vex-table",
thead {
tr {
th { {crate::i18n::texts::vex::CVE.get(lang)} }
th { {tx::COL_PART.get(lang)} }
th { {crate::i18n::texts::vex::STATUS.get(lang)} }
th { {crate::i18n::texts::vex::SUPPLIER_SAYS.get(lang)} }
th { span { class: "sr-only", {crate::i18n::texts::vex::ACTIONS.get(lang)} } }
}
}
tbody {
for alert in rows.iter() {
{
let status = status_of(alert);
let part = parts.get(&alert.repo_id).cloned();
let stated_by = alert.vex.as_ref().filter(|v| !v.by_scan).map(|v| v.by_name.clone().unwrap_or_else(|| v.by.clone()));
rsx! {
tr { key: "{alert.repo_id}-{alert.cve_id}",
td {
code { "{alert.cve_id}" }
for adv in alert.advisories.iter() {
div { class: "vex-advisory-line",
a {
class: "vex-advisory",
href: adv.url.clone().unwrap_or_default(),
target: "_blank",
rel: "noopener noreferrer",
"{adv.id}"
}
if adv.provider.starts_with(SUPPLIER_PROVIDER_PREFIX) {
" "
span { class: "vex-advisory-note", {crate::i18n::texts::vex::SUPPLIER_ADVISORY.get(lang)} }
}
}
}
}
td {
if let Some(part) = part.clone() {
"{part.name} "
OriginBadge { part }
}
}
td {
span { class: status_class(status), {status_text(status).get(lang)} }
if let Some(by) = stated_by {
" "
span { class: "target-muted", "{by}" }
}
}
td {
match &alert.supplier_vex {
Some(vex) => rsx! {
span { class: "vex-supplier-pill",
span { class: status_class(vex.status), {status_text(vex.status).get(lang)} }
"{supplier_gist(vex, lang)}"
}
},
None => rsx! { span { class: "target-muted", "—" } },
}
}
td {
Link {
class: "btn btn-secondary btn-sm",
to: Route::target_view(alert.repo_id.clone(), RepoView::Cves),
{tx::ASSESS_IN_PART.get(lang)}
}
}
}
}
}
}
}
}
}
}
}
}
}
/// What one scan of a part changed, in words: a supplier's new version, or
/// a scan (the first one marked as such).
fn change_title(change: &MachineChangeDto, part: Option<&PartDto>, lang: Lang) -> (String, String) {
let rows = change.change.components.as_deref().unwrap_or_default();
let product = part
.and_then(|p| p.supplier.as_ref())
.and_then(|s| s.product.as_deref());
let new_version = rows
.iter()
.find(|r| r.kind == ComponentRowKind::Updated && product.is_some_and(|p| p == r.name));
let added = rows
.iter()
.filter(|r| r.kind == ComponentRowKind::Added)
.count();
let removed = rows
.iter()
.filter(|r| r.kind == ComponentRowKind::Removed)
.count();
let moves = if added + removed > 0 {
tx::component_moves(added, removed, lang)
} else {
String::new()
};
match new_version {
Some(row) => (
format!(
"{}: {} {} → {}",
tx::NEW_VERSION.get(lang),
row.name,
row.from.as_deref().unwrap_or("?"),
row.to.as_deref().unwrap_or("?")
),
moves,
),
None if change.change.baseline => (
tx::SCAN.get(lang).to_string(),
tx::BASELINE.get(lang).to_string(),
),
None => (tx::SCAN.get(lang).to_string(), moves),
}
}
/// The machine's history: its parts' scans, newest first.
#[component]
fn HistoryTab(id: String, data: MachineOverviewDto) -> Element {
let lang = use_lang()();
let machine_id = use_signal(|| id.clone());
let changes = use_resource(move || async move { fetch_machine_changes(machine_id()).await });
let now = chrono::Utc::now();
let read = changes.read();
let Some(result) = &*read else {
return rsx! { div { class: "loading", {common::LOADING.get(lang)} } };
};
let Ok(list) = result else {
return rsx! { p { class: "target-muted", {tx::LOAD_FAILED.get(lang)} } };
};
rsx! {
p { class: "target-muted", {tx::HISTORY_HINT.get(lang)} }
if list.is_empty() {
p { class: "target-muted", {tx::NO_HISTORY.get(lang)} }
} else {
section { class: "card",
div { class: "table-wrapper",
table { class: "machine-table",
thead {
tr {
th { {tx::COL_WHEN.get(lang)} }
th { {tx::COL_PART.get(lang)} }
th { {tx::COL_WHAT.get(lang)} }
th { {tx::COL_NEW.get(lang)} }
th { {tx::COL_GONE.get(lang)} }
th { span { class: "sr-only", {tx::IN_PART.get(lang)} } }
}
}
tbody {
for change in list.iter() {
{
let part = data.part(&change.part).cloned();
let (title, detail) = change_title(change, part.as_ref(), lang);
let when = change.change.completed_at.unwrap_or(change.change.started_at);
let new = change.change.new_cves.len();
let gone = change.change.gone_cves.len();
rsx! {
tr { key: "{change.change.run_id}",
td { class: "target-muted machine-nowrap",
title: format_time(&when, lang),
{format_ago(&when, &now, lang)}
}
td {
if let Some(part) = part.clone() {
"{part.name} "
OriginBadge { part }
}
}
td {
strong { "{title}" }
if !detail.is_empty() {
div { class: "target-muted", "{detail}" }
}
}
td {
if new > 0 {
span { class: "badge badge-danger", "+{new}" }
} else {
span { class: "target-muted", "—" }
}
}
td {
if gone > 0 {
span { class: "badge badge-success", "−{gone}" }
} else {
span { class: "target-muted", "—" }
}
}
td {
Link {
class: "machine-nowrap",
to: Route::target_view(change.part.clone(), RepoView::History),
{tx::IN_PART.get(lang)}
}
}
}
}
}
}
}
}
}
}
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use compliance_core::scan_changes::{ComponentRow, ScanChange};
fn change(rows: Vec<ComponentRow>, baseline: bool) -> MachineChangeDto {
MachineChangeDto {
part: "t2".into(),
change: serde_json::from_value(serde_json::json!({
"run_id": "r1", "status": "completed",
"started_at": "2026-11-17T03:00:00Z", "baseline": baseline,
"new_cves": [], "gone_cves": [],
}))
.map(|mut c: ScanChange| {
c.components = Some(rows);
c
})
.unwrap(),
}
}
fn row(
kind: ComponentRowKind,
name: &str,
from: Option<&str>,
to: Option<&str>,
) -> ComponentRow {
ComponentRow {
kind,
name: name.into(),
from: from.map(String::from),
to: to.map(String::from),
cves_new: 0,
cves_gone: 0,
}
}
#[test]
fn a_suppliers_new_version_reads_as_such_with_the_components_it_moved() {
let part: PartDto = serde_json::from_value(serde_json::json!({
"id": "t2", "name": "Antrieb", "target_type": "firmware_rtos",
"supplier": { "name": "Example Drives", "product": "Drive Control", "version": "4.3.0" },
"open": { "critical": 0, "high": 0, "medium": 0, "low": 0, "info": 0 },
}))
.unwrap();
let updated = change(
vec![
row(
ComponentRowKind::Updated,
"Drive Control",
Some("4.2.1"),
Some("4.3.0"),
),
row(ComponentRowKind::Added, "zstd", None, Some("1.5")),
row(ComponentRowKind::Removed, "zlib", Some("1.2"), None),
],
false,
);
assert_eq!(
change_title(&updated, Some(&part), Lang::De),
(
"Neue Version des Zulieferers: Drive Control 4.2.1 → 4.3.0".to_string(),
"Komponenten +1, −1".to_string()
)
);
// The same update in a part made in-house is a scan.
assert_eq!(change_title(&updated, None, Lang::En).0, "Scan");
assert_eq!(
change_title(&change(Vec::new(), true), None, Lang::De),
(
"Prüfung".to_string(),
"die erste: legt den Stand fest".to_string()
)
);
}
#[test]
fn only_the_severities_with_cves_get_a_badge() {
let counts = SeverityCounts {
critical: 1,
high: 0,
medium: 6,
low: 0,
info: 0,
};
assert_eq!(
count_badges(&counts, Lang::De),
[
("badge badge-critical", "1 kritisch".to_string()),
("badge badge-medium", "6 mittel".to_string())
]
);
assert_eq!(total(&counts), 7);
}
}
+2
View File
@@ -12,6 +12,7 @@ pub(crate) mod graph_view;
pub mod impact_analysis;
pub mod inbox;
pub mod issues;
pub mod machine;
pub mod mcp_servers;
pub mod mcp_tokens;
pub mod onboarding;
@@ -36,6 +37,7 @@ pub use graph_explorer::GraphExplorerPage;
pub use impact_analysis::ImpactAnalysisPage;
pub use inbox::HeutePage;
pub use issues::IssuesPage;
pub use machine::MachinePage;
pub use mcp_servers::McpServersPage;
pub use mcp_tokens::McpTokensPage;
pub use onboarding::OnboardingPage;
+8 -2
View File
@@ -22,7 +22,7 @@ use crate::pages::inbox::{bucket_texts, bucket_tone};
use crate::pages::target_views::RepoView;
use compliance_core::cve_history::{CveDay, CveHistory};
use compliance_core::models::inbox::{Bucket, InboxCounts, InboxTarget};
use compliance_core::models::{Project, ScanRun, ScanRunStatus};
use compliance_core::models::{Project, ProjectKind, ScanRun, ScanRunStatus};
/// Open findings the "Next up" list shows.
const NEXT_UP: usize = 6;
@@ -355,7 +355,13 @@ fn ProjectSection(group: ProjectGroup, only: bool, lang: Lang) -> Element {
div { class: "ov-project",
div { class: "ov-project-head",
div { class: "ov-project-title",
h4 { "{name}" }
// A product is a machine (#1026), with a page of its own.
match group.project.as_ref().filter(|p| p.kind == ProjectKind::Product) {
Some(p) => rsx! {
h4 { Link { to: Route::MachinePage { id: p.id.clone(), tab: String::new() }, "{name}" } }
},
None => rsx! { h4 { "{name}" } },
}
span { "{summary}" }
}
if !trend.is_empty() {
+13
View File
@@ -529,6 +529,19 @@ naming its part (`part`) and what it changed, as in a target's history. A
supplier's new version shows as its product updated (`from` → `to`) in a
part bought in.
In the dashboard, a product project's name on **Übersicht** opens the
machine's page (`/projects/{id}`). It has three tabs:
- **Bestandteile:** the figures across the machine and each part with its
origin, version, open CVEs and last scan. It also offers the machine SBOM to
download.
- **Schwachstellen:** the open CVEs by component, each row a part with its
status and what its supplier says. You assess each one in the part.
- **Verlauf:** the parts' scans, a supplier's new version among them.
The machine's VEX, CSAF and evidence pack follow; until then each part has
its own.
## VEX: the status of each vulnerability
For each known vulnerability (CVE alert) of a target you state whether the