feat(dashboard): bought-in components with their supplier's SBOM and VEX (#1025) (#1035)
CI / Check (push) Skipped
CI / Agent integration (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy MCP (push) Skipped
CI / Deploy Docs (push) Successful in 1m4s
CI / Deploy Dashboard (push) Successful in 4m32s
CI / Deploy Agent (push) Successful in 5m53s

This commit was merged in pull request #1035.
This commit is contained in:
sharang committed 2026-11-17 10:13:59 +00:00
1 parent 72ef09b981
commit b5a2dd93fd
8 files changed
+1605 -82

No files matched your search

+219 -7
View File
@@ -3754,7 +3754,7 @@ tbody tr:last-child td {
justify-content: center;
gap: 8px;
padding: 16px 24px;
border-bottom: 1px solid var(--border-color);
border-bottom: 1px solid var(--border);
background: var(--bg-primary);
}
@@ -3772,16 +3772,17 @@ tbody tr:last-child td {
display: block;
width: 24px;
height: 1px;
background: var(--border-color);
background: var(--border-bright);
margin-right: 4px;
}
.wizard-step.active {
color: var(--accent);
font-weight: 600;
}
.wizard-step.completed {
color: var(--status-success);
color: var(--success);
}
.wizard-step-dot {
@@ -3793,19 +3794,22 @@ tbody tr:last-child td {
justify-content: center;
font-size: 0.7rem;
font-weight: 700;
background: var(--bg-tertiary);
background: transparent;
border: 1px solid var(--border-bright);
color: var(--text-tertiary);
flex-shrink: 0;
}
.wizard-step.active .wizard-step-dot {
background: var(--accent);
color: var(--bg-primary);
border-color: var(--accent);
color: var(--accent-ink);
}
.wizard-step.completed .wizard-step-dot {
background: var(--status-success);
color: var(--bg-primary);
background: var(--success-bg);
border-color: transparent;
color: var(--success);
}
.wizard-step-label {
@@ -8264,3 +8268,211 @@ span.repo-crumb-name {
margin-top: 12px;
font-size: 12.5px;
}
/* ── Bought-in components and their supplier (#1025) ── */
.badge-new,
.badge-accent {
background: var(--accent-muted);
color: var(--accent);
border-color: var(--border-accent);
}
.badge-new {
margin-left: 4px;
vertical-align: middle;
}
.origin-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
max-width: 720px;
}
.supplier-box {
display: flex;
flex-direction: column;
gap: 12px;
max-width: 720px;
margin-top: 14px;
padding: 14px 16px;
border: 1px solid var(--border);
border-radius: var(--radius-lg);
background: var(--bg-card-hover);
}
.supplier-box .form-group {
margin: 0;
}
.supplier-box-title {
margin: 0;
}
.supplier-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
.form-hint {
margin-top: 6px;
font-size: 12px;
color: var(--text-tertiary);
}
.form-error {
margin-top: 4px;
font-size: 12px;
color: var(--danger);
}
.callout-accent {
margin: 12px 16px 0;
padding: 10px 14px;
border: 1px solid var(--border-accent);
border-radius: var(--radius);
background: var(--accent-muted);
font-size: 12.5px;
color: var(--text-tertiary);
line-height: 1.55;
}
.callout-accent > div:first-child {
color: var(--text-primary);
}
.staged-file {
display: flex;
flex-wrap: nowrap;
gap: 12px;
justify-content: space-between;
align-items: center;
margin-top: 6px;
padding: 8px 12px;
border: 1px solid var(--border);
border-radius: var(--radius);
}
.staged-file.is-refused {
border-color: color-mix(in oklch, var(--danger) 35%, var(--border));
background: var(--danger-bg);
}
.staged-file-name {
display: flex;
flex: 1 1 0;
min-width: 0;
flex-wrap: wrap;
gap: 4px 10px;
align-items: center;
overflow-wrap: anywhere;
}
.staged-file.is-refused .staged-file-name {
flex-direction: column;
align-items: flex-start;
}
.staged-file-refusal {
font-size: 12px;
color: var(--danger);
}
.artifact-row-facts {
display: block;
margin-top: 3px;
font-size: 12px;
color: var(--text-tertiary);
}
.supplier-advisories {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
margin-top: 6px;
}
.supplier-advisories .form-hint {
margin-top: 0;
}
.vex-advisory-line .vex-advisory {
display: inline;
}
.vex-advisory-note {
font-size: 11px;
color: var(--text-tertiary);
}
.vex-supplier-pill {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 2px 8px;
border: 1px solid var(--border-bright);
border-radius: 999px;
background: var(--bg-card-hover);
font-size: 11.5px;
color: var(--text-secondary);
white-space: nowrap;
}
.vex-table tr.is-open {
background: var(--bg-elevated);
}
.vex-footnote {
margin: 8px 0 0;
font-size: 12px;
}
.vex-editor-with-supplier {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 18px;
align-items: start;
}
.vex-supplier-card {
display: flex;
flex-direction: column;
gap: 6px;
margin: 8px 0;
padding: 12px 14px;
border: 1px solid var(--border);
border-radius: var(--radius-lg);
background: var(--bg-card);
font-size: 12.5px;
}
.vex-supplier-card p {
margin: 0;
}
.vex-supplier-label {
font-family: var(--font-mono);
font-size: 10px;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--text-tertiary);
}
.vex-supplier-status {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
}
@media (max-width: 720px) {
.origin-grid,
.supplier-grid,
.vex-editor-with-supplier {
grid-template-columns: minmax(0, 1fr);
}
}
@@ -1,21 +1,28 @@
//! Add a file (an archive, a PLC project, a firmware image) to an existing
//! target: upload it at once, with its archive password if it has one.
//! Add a file (an archive, a PLC project, a firmware image, a supplier SBOM)
//! to an existing target: upload it at once, with its archive password if it
//! has one.
use dioxus::prelude::*;
use crate::i18n::texts::{common, kinds, onboarding as otx, targets as tx};
use crate::i18n::use_lang;
use crate::infrastructure::onboarding::{
is_file_kind, plc_format_for, set_archive_password, trigger_new_content_scan,
upload_target_artifact, ArchivePassword, PasswordOutcome, UNSUPPORTED_ARCHIVE,
is_file_kind, may_need_password, plc_format_for, set_archive_password,
trigger_new_content_scan, upload_problem, upload_target_artifact, ArchivePassword,
PasswordOutcome,
};
/// The upload row for target `target_id`; `on_uploaded` runs once the file
/// (and its password, if it needs one) is stored.
/// The upload row for target `target_id`, starting with file kind `kind`;
/// `on_uploaded` runs once the file (and its password, if it needs one) is
/// stored.
#[component]
pub fn ArtifactUpload(target_id: String, on_uploaded: EventHandler<()>) -> Element {
pub fn ArtifactUpload(
target_id: String,
#[props(default = "source_archive")] kind: &'static str,
on_uploaded: EventHandler<()>,
) -> Element {
let lang = use_lang()();
let mut kind = use_signal(|| "source_archive".to_string());
let mut kind = use_signal(|| kind.to_string());
let mut plc_format = use_signal(|| "plcopen_xml".to_string());
let mut file = use_signal(|| Option::<dioxus::html::FileData>::None);
let mut password = use_signal(String::new);
@@ -64,8 +71,8 @@ pub fn ArtifactUpload(target_id: String, on_uploaded: EventHandler<()>) -> Eleme
}
}
}
// Firmware images and build outputs are never unpacked.
if kind() != "firmware_image" && kind() != "build_output" {
// Firmware images, build outputs and SBOMs are never unpacked.
if may_need_password(&kind()) {
div { class: "form-group artifact-upload-password",
label { {common::ARCHIVE_PASSWORD.get(lang)} }
input {
@@ -89,10 +96,12 @@ pub fn ArtifactUpload(target_id: String, on_uploaded: EventHandler<()>) -> Eleme
let result = match upload_target_artifact(id.clone(), kind, format, picked.into()).await {
Err(e) => {
let e = e.to_string();
Err(if e.contains(UNSUPPORTED_ARCHIVE) {
common::UNSUPPORTED_ARCHIVE.get(lang).to_string()
} else {
let problem = upload_problem(e.clone(), lang);
// The agent's own words follow "upload failed".
Err(if problem == e {
format!("{}: {e}", otx::UPLOAD_FAILED.get(lang))
} else {
problem
})
}
Ok(resp) => {
+265 -15
View File
@@ -12,7 +12,7 @@ use dioxus_free_icons::Icon;
use compliance_core::cve_groups::{CveGroup, CveSeverity, PackageKey};
use compliance_core::cve_matrix::CveFilter;
use compliance_core::models::{CveAlert, VexAssessment, VexJustification, VexStatus};
use compliance_core::models::{CveAlert, SupplierVex, VexAssessment, VexJustification, VexStatus};
use compliance_core::vex_docs::status_of;
use crate::components::no_access::use_can_write;
@@ -99,6 +99,89 @@ fn missing(statement: &VexStatementDto) -> Option<Text> {
}
}
/// The justification a supplier's CycloneDX `justification` stands for, where
/// the two mean the same; `None` leaves the choice to the person.
fn justification_of_supplier(cyclonedx: &str) -> Option<VexJustification> {
match cyclonedx {
"code_not_present" => Some(VexJustification::VulnerableCodeNotPresent),
"code_not_reachable" => Some(VexJustification::VulnerableCodeNotInExecutePath),
_ => None,
}
}
/// A supplier's CycloneDX justification in words, else as written.
fn supplier_justification_words(value: &str, lang: Lang) -> String {
tx::supplier_justification(value).map_or_else(|| value.to_string(), |t| t.get(lang).to_string())
}
/// A supplier's CycloneDX responses in words, else as written.
fn supplier_response_words(responses: &[String], lang: Lang) -> String {
responses
.iter()
.map(|r| tx::supplier_response(r).map_or_else(|| r.clone(), |t| t.get(lang).to_string()))
.collect::<Vec<_>>()
.join(", ")
}
/// 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 {
/// Longer words are left for the statement's panel.
const SHORT: usize = 60;
match (&vex.justification, vex.detail.as_deref().map(str::trim)) {
(Some(j), _) => supplier_justification_words(j, lang),
(None, Some(detail)) if !detail.is_empty() && detail.chars().count() <= SHORT => {
detail.to_string()
}
(None, _) => supplier_response_words(&vex.response, lang),
}
}
/// The form a supplier's statement fills in, as (status, justification,
/// impact statement, action statement): the supplier's words, marked as
/// theirs, in the field its status asks for. Nothing is stored by this.
fn copied_from_supplier(
vex: &SupplierVex,
lang: Lang,
) -> (VexStatus, Option<VexJustification>, String, String) {
let words = vex
.detail
.clone()
.filter(|d| !d.trim().is_empty())
.unwrap_or_else(|| supplier_gist(vex, lang));
let text = if words.trim().is_empty() {
String::new()
} else {
format!("{}: {words}", tx::PER_SUPPLIER.get(lang))
};
let (impact, action) = match vex.status {
VexStatus::NotAffected => (text, String::new()),
VexStatus::Affected => (String::new(), text),
VexStatus::UnderInvestigation | VexStatus::Fixed => (String::new(), String::new()),
};
let justification = vex
.justification
.as_deref()
.and_then(justification_of_supplier)
.filter(|_| vex.status == VexStatus::NotAffected);
(vex.status, justification, impact, action)
}
/// 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 {
alert.purl.is_none()
&& alert
.advisories
.iter()
.any(|a| a.provider.starts_with(SUPPLIER_PROVIDER_PREFIX))
}
/// 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:";
/// Who made an alert's statement: the person's name, "Prüfung" for a scan.
fn stated_by(alert: &CveAlert, lang: Lang) -> String {
match &alert.vex {
@@ -138,10 +221,21 @@ pub fn VexPanel(target_id: String, #[props(default)] filter: Option<CveFilter>)
groups.restart();
};
let candidates = enisa.read().clone().unwrap_or_default();
let supplier_states = alerts
.read()
.as_ref()
.and_then(|a| a.as_ref())
.is_some_and(|list| list.iter().any(|a| a.supplier_vex.is_some()));
rsx! {
div { class: "vex-head",
p { class: "target-muted", {tx::HINT.get(lang)} }
p { class: "target-muted",
{tx::HINT.get(lang)}
if supplier_states {
" "
{tx::SUPPLIER_HINT.get(lang)}
}
}
div { class: "vex-exports",
for format in [VexFormat::OpenVex, VexFormat::CycloneDx] {
VexExportButton { target_id: target_id.clone(), format }
@@ -316,6 +410,9 @@ fn CveTable(
let lang = use_lang()();
let can_write = use_can_write();
let mut editing = use_signal(|| Option::<String>::None);
// The supplier's column only where a supplier states something (#1025).
let supplier = alerts.iter().any(|a| a.supplier_vex.is_some());
let columns = if supplier { "7" } else { "6" };
rsx! {
div { class: "table-wrapper",
table { class: "vex-table",
@@ -326,7 +423,10 @@ fn CveTable(
th { {tx::SEVERITY.get(lang)} }
th { {tx::STATUS.get(lang)} }
th { {tx::STATED_BY.get(lang)} }
th {}
if supplier {
th { {tx::SUPPLIER_SAYS.get(lang)} }
}
th { span { class: "sr-only", {tx::ACTIONS.get(lang)} } }
}
}
tbody {
@@ -338,29 +438,54 @@ fn CveTable(
let edit_id = alert_id.clone();
let current = alert.vex.clone().filter(|v| !v.by_scan);
let initial = current.as_ref().map_or(status, |v| v.status);
let supplier_product = is_supplier_product(alert);
rsx! {
tr { key: "{alert_id}",
tr { key: "{alert_id}", class: if open { "is-open" } else { "" },
td {
code { "{alert.cve_id}" }
// The vendor advisories that name it (#515), linked as
// their terms ask; the remediation on hover.
for adv in alert.advisories.iter() {
a {
class: "vex-advisory",
href: adv.url.clone().unwrap_or_default(),
target: "_blank",
rel: "noopener noreferrer",
title: adv.remediation.clone().unwrap_or_else(|| adv.title.clone()),
"{adv.id}"
div { class: "vex-advisory-line",
a {
class: "vex-advisory",
href: adv.url.clone().unwrap_or_default(),
target: "_blank",
rel: "noopener noreferrer",
title: adv.remediation.clone().unwrap_or_else(|| adv.title.clone()),
"{adv.id}"
}
if adv.provider.starts_with(SUPPLIER_PROVIDER_PREFIX) {
" "
span { class: "vex-advisory-note", {tx::SUPPLIER_ADVISORY.get(lang)} }
}
}
}
}
td { "{alert.affected_package} {alert.affected_version}" }
td {
"{alert.affected_package} {alert.affected_version}"
if supplier_product {
div { class: "vex-advisory-note", {tx::SUPPLIER_PRODUCT.get(lang)} }
}
}
// The severity the groups count it with (#949): the
// advisory's rating, else its CVSS score, else info.
td { SeverityBadge { severity: CveSeverity::of(alert).as_str().to_string() } }
td { span { class: status_class(status), {status_text(status).get(lang)} } }
td { class: "target-muted", "{stated_by(alert, lang)}" }
if supplier {
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 {
if can_write && !open {
button {
@@ -376,10 +501,11 @@ fn CveTable(
}
if open {
tr { class: "vex-editor-row",
td { colspan: "6",
td { colspan: columns,
VexEditor {
current,
initial,
supplier: alert.supplier_vex.clone(),
save: SaveTo::Alert(alert_id.clone()),
on_close: move |saved: bool| {
editing.set(None);
@@ -397,6 +523,9 @@ fn CveTable(
}
}
}
if supplier {
p { class: "target-muted vex-footnote", {tx::SUPPLIER_FOOTNOTE.get(lang)} }
}
}
}
@@ -606,12 +735,14 @@ impl SaveTo {
}
/// The statement editor, starting from `current` (a person's statement, if
/// any) with status `initial`, for one alert or a whole group. `on_close`
/// gets whether a statement was saved.
/// any) with status `initial`, for one alert or a whole group. With the
/// `supplier`'s statement, that is shown beside it and can be copied into the
/// form (#1025). `on_close` gets whether a statement was saved.
#[component]
fn VexEditor(
current: Option<VexAssessment>,
initial: VexStatus,
#[props(default)] supplier: Option<SupplierVex>,
save: SaveTo,
on_close: EventHandler<bool>,
) -> Element {
@@ -645,6 +776,46 @@ fn VexEditor(
let blocked = missing(&statement);
rsx! {
div { class: if supplier.is_some() { "vex-editor-with-supplier" } else { "" },
if let Some(vex) = supplier.clone() {
div { class: "vex-supplier-card",
span { class: "vex-supplier-label", {tx::SUPPLIER_STATEMENT.get(lang)} }
div { class: "vex-supplier-status",
span { class: status_class(vex.status), {status_text(vex.status).get(lang)} }
span { class: "target-muted",
if let Some(j) = &vex.justification {
"{tx::SUPPLIER_JUSTIFICATION.get(lang)}: {supplier_justification_words(j, lang)}"
}
if vex.justification.is_some() && !vex.response.is_empty() { " · " }
if !vex.response.is_empty() {
"{tx::SUPPLIER_RESPONSE.get(lang)}: {supplier_response_words(&vex.response, lang)}"
}
}
}
if let Some(detail) = vex.detail.as_deref().filter(|d| !d.trim().is_empty()) {
div { "„{detail}“" }
}
div { class: "target-muted",
"{tx::SUPPLIER_FROM.get(lang)} "
code { "{vex.source}" }
" · {tx::SUPPLIER_REREAD.get(lang)}"
}
div {
button {
class: "btn btn-secondary btn-sm",
onclick: move |_| {
let (s, j, i, a) = copied_from_supplier(&vex, lang);
status.set(s);
justification.set(j);
impact.set(i);
action.set(a);
},
{tx::COPY_SUPPLIER.get(lang)}
}
}
p { class: "target-muted", {tx::COPY_SUPPLIER_HINT.get(lang)} }
}
}
div { class: "vex-editor",
label {
{tx::STATUS.get(lang)}
@@ -713,6 +884,7 @@ fn VexEditor(
}
}
}
}
}
}
@@ -816,6 +988,84 @@ mod tests {
assert_eq!(reportable_candidate(&candidates, "a3"), None);
}
fn supplier(
state: VexStatus,
justification: Option<&str>,
detail: Option<&str>,
) -> SupplierVex {
SupplierVex {
status: state,
state: String::new(),
justification: justification.map(String::from),
detail: detail.map(String::from),
response: vec!["will_not_fix".into()],
source: "drive-control.cdx.json".into(),
}
}
#[test]
fn a_suppliers_statement_fills_the_form_as_theirs() {
let not_affected = supplier(
VexStatus::NotAffected,
Some("code_not_reachable"),
Some("template() is never called."),
);
assert_eq!(
copied_from_supplier(&not_affected, Lang::De),
(
VexStatus::NotAffected,
Some(VexJustification::VulnerableCodeNotInExecutePath),
"Laut Lieferant: template() is never called.".to_string(),
String::new(),
)
);
// A justification without an equal is left for the person; the
// supplier's words still give the reason.
let configured = supplier(VexStatus::NotAffected, Some("requires_configuration"), None);
let (_, justification, impact, _) = copied_from_supplier(&configured, Lang::En);
assert_eq!(justification, None);
assert_eq!(impact, "Per the supplier: Requires a configuration");
assert_eq!(
missing(&VexStatementDto {
status: VexStatus::NotAffected,
justification,
impact_statement: Some(impact),
action_statement: None,
}),
None
);
let short = supplier(VexStatus::Affected, None, Some("Update auf 4.3.0"));
assert_eq!(supplier_gist(&short, Lang::De), "Update auf 4.3.0");
// Affected: what to do goes where the agent asks for it.
let affected = supplier(VexStatus::Affected, None, None);
let (status, _, impact, action) = copied_from_supplier(&affected, Lang::De);
assert_eq!(status, VexStatus::Affected);
assert!(impact.is_empty());
assert_eq!(action, "Laut Lieferant: Wird nicht behoben");
}
#[test]
fn a_supplier_advisory_on_a_component_without_purl_is_about_the_product() {
let mut alert: CveAlert = serde_json::from_value(serde_json::json!({
"cve_id": "CVE-2026-90001", "repo_id": "t", "affected_package": "Drive Control",
"affected_version": "4.2.1", "source": "osv", "created_at": "2026-11-16T00:00:00Z",
"references": [], "severity": null, "cvss_score": null, "summary": null,
"llm_impact_summary": null,
}))
.unwrap();
assert!(!is_supplier_product(&alert));
alert.advisories.push(compliance_core::models::AdvisoryRef {
provider: "supplier:https://psirt.example/provider-metadata.json".into(),
id: "BAT-2026-0007".into(),
title: String::new(),
url: None,
remediation: None,
});
assert!(is_supplier_product(&alert));
alert.purl = Some("pkg:npm/lodash@4.17.20".into());
assert!(!is_supplier_product(&alert));
}
#[test]
fn options_round_trip_through_their_wire_names() {
for s in STATUSES {
+373 -5
View File
@@ -1018,6 +1018,86 @@ pub mod scans {
pub mod targets {
use super::Text;
/// The editor's supplier section (#1025).
pub const SUPPLIER_SECTION: Text = Text {
de: "Zulieferer",
en: "Supplier",
};
pub const SUPPLIER_CSAF: Text = Text {
de: "Sicherheitshinweise des Zulieferers (CSAF)",
en: "The supplier's security advisories (CSAF)",
};
pub const SUPPLIER_EDIT_HINT: Text = Text {
de: "Ein Zulieferer ohne Namen wird entfernt. Die Adresse muss mit https beginnen.",
en: "A supplier without a name is removed. The address must start with https.",
};
pub const ADVISORIES_NOT_READ: Text = Text {
de: "noch nicht gelesen",
en: "not read yet",
};
pub const ADVISORIES_UNREACHABLE: Text = Text {
de: "nicht erreichbar",
en: "unreachable",
};
pub const ADVISORIES_READ_AFTER_SAVE: Text = Text {
de: "Nach dem Speichern liest Prüfwerk die Hinweise gleich, danach täglich.",
en: "Once saved, Prüfwerk reads the advisories at once, then daily.",
};
/// "14 Hinweise gelesen".
pub fn advisories_read(n: u64, lang: super::super::Lang) -> String {
match (lang, n) {
(super::super::Lang::De, 1) => "1 Hinweis gelesen".to_string(),
(super::super::Lang::De, n) => format!("{n} Hinweise gelesen"),
(super::super::Lang::En, 1) => "1 advisory read".to_string(),
(super::super::Lang::En, n) => format!("{n} advisories read"),
}
}
/// "zuletzt vor 2 Std. · nur für Ihren Arbeitsbereich".
pub fn advisories_checked(ago: &str, lang: super::super::Lang) -> String {
match lang {
super::super::Lang::De => format!("zuletzt {ago} · nur für Ihren Arbeitsbereich"),
super::super::Lang::En => format!("last {ago} · for your workspace only"),
}
}
/// What an upload kept of a supplier SBOM: `CycloneDX 1.5 · 212
/// Komponenten · 9 Aussagen des Lieferanten · hochgeladen am 16.11.2026`.
pub fn sbom_facts(
summary: Option<(&str, usize, usize)>,
uploaded: Option<&str>,
lang: super::super::Lang,
) -> String {
use super::super::{format_count, Lang};
let mut parts = Vec::with_capacity(4);
if let Some((format, components, statements)) = summary {
let (c, st) = (
format_count(components as u64, lang),
format_count(statements as u64, lang),
);
parts.push(format.to_string());
parts.push(match lang {
Lang::De => format!("{c} Komponenten"),
Lang::En => format!("{c} components"),
});
parts.push(match lang {
Lang::De => format!("{st} Aussagen des Lieferanten"),
Lang::En => format!("{st} supplier statements"),
});
}
if let Some(date) = uploaded {
parts.push(match lang {
Lang::De => format!("hochgeladen am {date}"),
Lang::En => format!("uploaded on {date}"),
});
}
parts.join(" · ")
}
pub const SBOM_REPLACES: Text = Text {
de: "Eine neue Zulieferer-SBOM ersetzt diese; die nächste Prüfung zeigt unter \
„Verlauf“, welche Schwachstellen dazugekommen oder weggefallen sind.",
en: "A new supplier SBOM replaces this one; the next scan shows under \"History\" \
which vulnerabilities came or went.",
};
/// How many targets the selection holds: "1 Prüfobjekt", "12 targets".
pub fn count(total: u64, lang: super::super::Lang) -> String {
match (lang, total) {
@@ -1372,10 +1452,10 @@ pub mod targets {
en: "Add a file",
};
pub const UPLOAD_HINT: Text = Text {
de: "Ein Archiv (zip, tar, tar.gz), ein SPS-Projekt oder ein Firmware-Image. Die Datei \
wird sofort hochgeladen und gleich danach geprüft.",
en: "An archive (zip, tar, tar.gz), a PLC project or a firmware image. It is uploaded \
at once and scanned right after.",
de: "Ein Archiv (zip, tar, tar.gz), ein SPS-Projekt, ein Firmware-Image oder die SBOM \
des Zulieferers. Die Datei wird sofort hochgeladen und gleich danach geprüft.",
en: "An archive (zip, tar, tar.gz), a PLC project, a firmware image or the supplier's \
SBOM. It is uploaded at once and scanned right after.",
};
pub const UPLOAD: Text = Text {
de: "Hochladen",
@@ -1617,7 +1697,7 @@ pub mod kinds {
pub const MACHINE_TYPES: usize = 4;
/// The artifact kinds, in the order the forms offer them.
pub const ARTIFACT_KINDS: [(&str, Text); 9] = [
pub const ARTIFACT_KINDS: [(&str, Text); 10] = [
(
"git_repo",
Text {
@@ -1681,6 +1761,13 @@ pub mod kinds {
en: "Description (text)",
},
),
(
"supplier_sbom",
Text {
de: "Zulieferer-SBOM (CycloneDX, SPDX 2.3)",
en: "Supplier SBOM (CycloneDX, SPDX 2.3)",
},
),
];
/// A target type's label; an unknown value is shown with spaces.
@@ -1739,6 +1826,148 @@ pub mod kinds {
/// The onboarding wizard.
pub mod onboarding {
use super::Text;
use crate::i18n::{format_count, Lang};
/// The "new" badge on what a release added to a form.
pub const NEW: Text = Text {
de: "neu",
en: "new",
};
pub const ORIGIN: Text = Text {
de: "Herkunft",
en: "Origin",
};
pub const ORIGIN_OWN: Text = Text {
de: "Selbst entwickelt",
en: "Developed in-house",
};
pub const ORIGIN_OWN_HINT: Text = Text {
de: "Wir haben den Code oder das Projekt: Git, Archiv, SPS-Projekt, Image",
en: "We have the code or the project: git, archive, PLC project, image",
};
pub const ORIGIN_BOUGHT: Text = Text {
de: "Von einem Zulieferer gekauft",
en: "Bought from a supplier",
};
pub const ORIGIN_BOUGHT_HINT: Text = Text {
de: "Oft ohne Quellcode, mit der Stückliste (SBOM) des Zulieferers",
en: "Often without source code, with the supplier's bill of materials (SBOM)",
};
pub const SUPPLIER: Text = Text {
de: "Zulieferer",
en: "Supplier",
};
pub const PRODUCT: Text = Text {
de: "Produkt",
en: "Product",
};
pub const VERSION: Text = Text {
de: "Version",
en: "Version",
};
pub const CSAF_OPTIONAL: Text = Text {
de: "Sicherheitshinweise des Zulieferers (CSAF, optional)",
en: "The supplier's security advisories (CSAF, optional)",
};
pub const CSAF_HINT: Text = Text {
de: "Prüfwerk liest die öffentlichen Hinweise des Zulieferers täglich und gleicht sie \
mit Produkt und Version ab. Nur für Ihren Arbeitsbereich.",
en: "Prüfwerk reads the supplier's public advisories daily and matches them against \
the product and version. For your workspace only.",
};
pub const CSAF_HTTPS: Text = Text {
de: "Die Adresse muss mit https beginnen.",
en: "The address must start with https.",
};
pub const PRODUCT_HINT: Text = Text {
de: "Produkt und Version so, wie der Zulieferer sie in seinen Hinweisen nennt. Ohne \
sie wird nur die Stückliste geprüft.",
en: "The product and version as the supplier names them in its advisories. Without \
them, only the bill of materials is checked.",
};
pub const SUPPLIER_NAME_NEEDED: Text = Text {
de: "Bitte den Zulieferer nennen.",
en: "Please name the supplier.",
};
pub const BOUGHT_TITLE: Text = Text {
de: "Zugekaufte Komponente",
en: "Bought-in component",
};
pub const BOUGHT_HINT: Text = Text {
de: "Ohne Quellcode genügt die Stückliste (SBOM) des Zulieferers: CycloneDX 1.4–1.6 \
(JSON oder XML) oder SPDX 2.3 JSON. Prüfwerk gleicht ihre Komponenten mit \
bekannten Schwachstellen ab. Hat der Zulieferer darin schon gesagt, was ihn \
betrifft (VEX), sehen Sie das bei jeder Schwachstelle.",
en: "Without source code, the supplier's bill of materials (SBOM) is enough: \
CycloneDX 1.4–1.6 (JSON or XML) or SPDX 2.3 JSON. Prüfwerk matches its \
components against known vulnerabilities. Where the supplier already states \
what affects it (VEX), you see that with each vulnerability.",
};
pub const SBOM_READ_ON_ADD: Text = Text {
de: "Die SBOM wird beim Hinzufügen gelesen: Eine Datei, die keine solche SBOM ist oder \
keine Komponenten nennt, wird sofort abgelehnt, nicht erst bei der Prüfung.",
en: "The SBOM is read when it is added: a file that is no such SBOM or lists no \
components is refused at once, not at the scan.",
};
pub const SBOM_CHECKING: Text = Text {
de: "wird gelesen …",
en: "reading …",
};
pub const REFUSED: Text = Text {
de: "Abgelehnt",
en: "Refused",
};
/// "from <supplier>", after a bought-in target's name and type.
pub const FROM: Text = Text {
de: "von",
en: "from",
};
/// What a readable supplier SBOM holds, as the wizard shows it:
/// `CycloneDX 1.5 · 212 Komponenten · 9 VEX-Aussagen`.
pub fn sbom_summary(format: &str, components: usize, statements: usize, lang: Lang) -> String {
let (c, st) = (
format_count(components as u64, lang),
format_count(statements as u64, lang),
);
match lang {
Lang::De => format!("{format} · {c} Komponenten · {st} VEX-Aussagen"),
Lang::En => format!("{format} · {c} components · {st} VEX statements"),
}
}
/// Why a supplier SBOM is refused, by the agent's code.
pub fn sbom_refusal(code: &str, lang: Lang) -> &'static str {
let text = match code {
"unknown_format" => Text {
de: "keine CycloneDX- (JSON oder XML) oder SPDX-2-JSON-Datei. Bitte die SBOM \
als CycloneDX 1.4–1.6 oder SPDX 2.3 JSON senden.",
en: "not a CycloneDX (JSON or XML) or SPDX 2 JSON file. Please send the SBOM \
as CycloneDX 1.4–1.6 or SPDX 2.3 JSON.",
},
"empty" => Text {
de: "die SBOM nennt keine Komponenten. Eine leere SBOM ließe alle bekannten \
Schwachstellen der Komponente als behoben erscheinen.",
en: "the SBOM lists no components. An empty SBOM would make every known \
vulnerability of the component look fixed.",
},
"too_many_components" => Text {
de: "die SBOM nennt mehr als 100.000 Komponenten.",
en: "the SBOM lists more than 100,000 components.",
},
"too_large" => Text {
de: "die SBOM ist größer als 20 MiB.",
en: "the SBOM is larger than 20 MiB.",
},
_ => Text {
de: "die Datei ist als SBOM erkannt, lässt sich aber nicht lesen; sie ist \
fehlerhaft oder unvollständig.",
en: "the file is recognised as an SBOM but cannot be read; it is malformed or \
incomplete.",
},
};
text.get(lang)
}
pub const TITLE: Text = Text {
de: "Prüfobjekt anlegen",
@@ -3361,6 +3590,145 @@ pub mod vex {
use crate::i18n::Lang;
use compliance_core::cve_groups::{CveGroup, CveSeverity};
/// What the hint adds once a supplier states something (#1025).
pub const SUPPLIER_HINT: Text = Text {
de: "Neu: was der Lieferant dazu in seiner SBOM sagt, steht daneben. Es ist seine \
Aussage, nicht Ihre: sie erledigt nichts und erscheint nicht in Ihren VEX- und \
CSAF-Exporten.",
en: "New: what the supplier says about it in its SBOM is shown alongside. It is the \
supplier's statement, not yours: it settles nothing and is not in your VEX and \
CSAF exports.",
};
pub const SUPPLIER_SAYS: Text = Text {
de: "Lieferant sagt",
en: "Supplier says",
};
pub const ACTIONS: Text = Text {
de: "Aktionen",
en: "Actions",
};
pub const SUPPLIER_STATEMENT: Text = Text {
de: "Aussage des Lieferanten",
en: "The supplier's statement",
};
pub const SUPPLIER_JUSTIFICATION: Text = Text {
de: "Begründung",
en: "Justification",
};
pub const SUPPLIER_RESPONSE: Text = Text {
de: "Antwort",
en: "Response",
};
pub const SUPPLIER_REREAD: Text = Text {
de: "bei jeder Prüfung neu gelesen",
en: "read again by every scan",
};
pub const SUPPLIER_FROM: Text = Text {
de: "aus",
en: "from",
};
pub const COPY_SUPPLIER: Text = Text {
de: "In meine Aussage übernehmen",
en: "Use as my statement",
};
pub const COPY_SUPPLIER_HINT: Text = Text {
de: "Übernimmt Status, Begründung und Text in Ihr Formular; gespeichert wird erst mit \
„Speichern“, als Ihre Aussage.",
en: "Copies status, justification and text into your form; nothing is stored until \
\"Save\", as your statement.",
};
/// What the copied text starts with: whose words they are.
pub const PER_SUPPLIER: Text = Text {
de: "Laut Lieferant",
en: "Per the supplier",
};
pub const SUPPLIER_ADVISORY: Text = Text {
de: "Hinweis des Zulieferers",
en: "Supplier advisory",
};
pub const SUPPLIER_PRODUCT: Text = Text {
de: "Produkt des Zulieferers",
en: "The supplier's product",
};
pub const SUPPLIER_FOOTNOTE: Text = Text {
de: "„—“: der Lieferant sagt nichts zu dieser Schwachstelle. Komponenten ohne purl \
stehen unter „Nicht ausgeführt“, nicht als frei von Schwachstellen.",
en: "\"—\": the supplier says nothing about this vulnerability. Components without a \
purl are listed under \"Not run\", not as free of vulnerabilities.",
};
/// A CycloneDX `analysis.justification` in words; `None` for one
/// CycloneDX does not define (shown as written).
pub fn supplier_justification(value: &str) -> Option<Text> {
Some(match value {
"code_not_present" => Text {
de: "Code nicht enthalten",
en: "Code not present",
},
"code_not_reachable" => Text {
de: "Code nicht erreichbar",
en: "Code not reachable",
},
"requires_configuration" => Text {
de: "Nur mit bestimmter Konfiguration",
en: "Requires a configuration",
},
"requires_dependency" => Text {
de: "Nur mit bestimmter Abhängigkeit",
en: "Requires a dependency",
},
"requires_environment" => Text {
de: "Nur in bestimmter Umgebung",
en: "Requires an environment",
},
"protected_by_compiler" => Text {
de: "Durch den Compiler geschützt",
en: "Protected by the compiler",
},
"protected_at_runtime" => Text {
de: "Zur Laufzeit geschützt",
en: "Protected at runtime",
},
"protected_at_perimeter" => Text {
de: "Am Perimeter geschützt",
en: "Protected at the perimeter",
},
"protected_by_mitigating_control" => Text {
de: "Durch eine Gegenmaßnahme geschützt",
en: "Protected by a mitigating control",
},
_ => return None,
})
}
/// A CycloneDX `analysis.response` in words; `None` for one CycloneDX
/// does not define (shown as written).
pub fn supplier_response(value: &str) -> Option<Text> {
Some(match value {
"can_not_fix" => Text {
de: "Nicht behebbar",
en: "Cannot fix",
},
"will_not_fix" => Text {
de: "Wird nicht behoben",
en: "Will not fix",
},
"update" => Text {
de: "Update",
en: "Update",
},
"rollback" => Text {
de: "Zurück auf eine frühere Version",
en: "Roll back",
},
"workaround_available" => Text {
de: "Umgehung verfügbar",
en: "Workaround available",
},
_ => return None,
})
}
pub const TITLE: Text = Text {
de: "Schwachstellen und VEX",
en: "Vulnerabilities and VEX",
@@ -35,6 +35,215 @@ pub struct ArtifactInputDto {
/// set. Display only, never sent.
#[serde(skip)]
pub archive_password: ArchivePassword,
/// What the upload kept of a supplier SBOM. Display only, never sent.
#[serde(skip)]
pub sbom: Option<SbomSummary>,
/// When the file was uploaded. Display only, never sent.
#[serde(skip)]
pub uploaded_at: Option<chrono::DateTime<chrono::Utc>>,
}
/// A moment as the agent returns it: BSON extended JSON
/// (`{"$date": {"$numberLong": "…"}}`) or an RFC 3339 string.
pub fn agent_time(value: &serde_json::Value) -> Option<chrono::DateTime<chrono::Utc>> {
if let Some(text) = value.as_str().or_else(|| value["$date"].as_str()) {
return chrono::DateTime::parse_from_rfc3339(text)
.ok()
.map(|t| t.with_timezone(&chrono::Utc));
}
let millis = value["$date"]["$numberLong"].as_str()?.parse().ok()?;
chrono::DateTime::from_timestamp_millis(millis)
}
/// An upload error in words: a refused supplier SBOM by its code, a 7z or
/// rar archive as such, anything else as the agent said it.
pub fn upload_problem(error: String, lang: Lang) -> String {
use crate::i18n::texts::{common, onboarding};
if let Some(code) = sbom_refusal_code(&error) {
format!(
"{}: {}",
onboarding::REFUSED.get(lang),
onboarding::sbom_refusal(code, lang)
)
} else if error.contains(UNSUPPORTED_ARCHIVE) {
common::UNSUPPORTED_ARCHIVE.get(lang).to_string()
} else {
error
}
}
/// Who supplies a bought-in component (#1025), as the wizard and the target
/// editor send it. An empty `name` removes the supplier.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct SupplierDto {
/// The supplier's name.
pub name: String,
/// Its name for the product.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub product: Option<String>,
/// The product's version in use.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
/// Its CSAF provider's `provider-metadata.json`, an https URL.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub csaf_provider: Option<String>,
}
impl SupplierDto {
/// The supplier of a stored target (as the agent returns it), if any.
pub fn of(target: &serde_json::Value) -> Option<Self> {
serde_json::from_value(target.get("supplier")?.clone()).ok()
}
/// The supplier from the form's fields: blank fields left out, so an
/// empty name stands for no supplier.
pub fn from_fields(name: &str, product: &str, version: &str, csaf_provider: &str) -> Self {
let filled = |v: &str| (!v.trim().is_empty()).then(|| v.trim().to_string());
Self {
name: name.trim().to_string(),
product: filled(product),
version: filled(version),
csaf_provider: filled(csaf_provider),
}
}
/// Whether the CSAF provider is unusable, as the agent would refuse it:
/// set, but not an https URL.
pub fn provider_is_invalid(csaf_provider: &str) -> bool {
let url = csaf_provider.trim();
!url.is_empty() && (!url.starts_with("https://") || url.contains(char::is_whitespace))
}
}
/// What a supplier SBOM holds (#1025), as the agent's check and an upload's
/// facts report it.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct SbomSummary {
/// The format and version, such as `CycloneDX 1.5`.
pub format: String,
/// The components it lists.
pub components: usize,
/// The supplier's statements about their vulnerabilities.
pub statements: usize,
}
impl SbomSummary {
/// The summary an upload kept with a stored supplier SBOM; `None` for
/// one uploaded before it was kept.
pub fn of(artifact: &serde_json::Value) -> Option<Self> {
let facts = artifact["detected"].as_array()?;
let fact = |key: &str| {
facts
.iter()
.find(|f| f["key"] == key)
.and_then(|f| f["value"].as_str())
};
Some(Self {
format: fact("sbom_format")?.to_string(),
components: fact("sbom_components")?.parse().ok()?,
statements: fact("sbom_statements")?.parse().ok()?,
})
}
}
/// The agent's verdict on a supplier SBOM before any target holds it.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum SbomCheck {
/// A scan can read it.
Readable(SbomSummary),
/// Refused: the agent's code (`empty`, `unknown_format`, …), worded by
/// [`crate::i18n::texts::onboarding::sbom_refusal`].
Refused(String),
}
/// The marker an upload error carries for a refused supplier SBOM, followed
/// by the agent's code.
pub const SBOM_REFUSED: &str = "supplier_sbom_refused:";
/// The agent's code of a refused supplier SBOM upload, from its error: the
/// lowercase word after [`SBOM_REFUSED`], whatever the error wraps it in.
pub fn sbom_refusal_code(error: &str) -> Option<&str> {
let rest = &error[error.find(SBOM_REFUSED)? + SBOM_REFUSED.len()..];
let end = rest
.find(|c: char| !(c.is_ascii_lowercase() || c == '_'))
.unwrap_or(rest.len());
(end > 0).then(|| &rest[..end])
}
/// Check a supplier SBOM before any target holds it, **streamed** to the
/// agent as for [`upload_target_artifact`]; nothing is stored.
#[post("/api/supplier-sbom-check")]
pub async fn check_supplier_sbom(
file: dioxus::fullstack::FileStream,
) -> Result<SbomCheck, ServerFnError> {
let filename = file.file_name().to_string();
let part =
reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(file)).file_name(filename);
let resp =
super::agent_client::agent_request(reqwest::Method::POST, "/api/v1/supplier-sboms/check")
.await?
.multipart(reqwest::multipart::Form::new().part("file", part))
.send()
.await
.map_err(|e| ServerFnError::new(e.to_string()))?;
match resp.status().as_u16() {
200 => {
#[derive(Deserialize)]
struct Body {
data: SbomSummary,
}
let body: Body = resp
.json()
.await
.map_err(|e| ServerFnError::new(e.to_string()))?;
Ok(SbomCheck::Readable(body.data))
}
413 => Ok(SbomCheck::Refused("too_large".to_string())),
422 => Ok(SbomCheck::Refused(refusal_code(resp).await)),
code => Err(ServerFnError::new(format!(
"the agent could not check the SBOM ({code})"
))),
}
}
/// The `code` of an agent's supplier SBOM refusal.
#[cfg(feature = "server")]
async fn refusal_code(resp: reqwest::Response) -> String {
resp.json::<serde_json::Value>()
.await
.ok()
.and_then(|b| b["code"].as_str().map(String::from))
.unwrap_or_else(|| "malformed".to_string())
}
/// How many of a target's supplier advisories are kept, and when its CSAF
/// provider was last read (#1025).
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct SupplierAdvisoriesDto {
/// The advisories kept for the workspace.
pub advisories: u64,
/// When the provider was last read; none before the first refresh.
pub checked_at: Option<chrono::DateTime<chrono::Utc>>,
/// Whether it could be read then; none before the first refresh.
pub reachable: Option<bool>,
}
/// The supplier advisories of target `id`; `None` without a CSAF provider.
#[server]
pub async fn fetch_supplier_advisories(
id: String,
) -> Result<Option<SupplierAdvisoriesDto>, ServerFnError> {
#[derive(Deserialize)]
struct Body {
data: Option<SupplierAdvisoriesDto>,
}
let resp = super::agent_client::agent_get(&format!("/api/v1/targets/{id}/supplier-advisories"))
.await?
.send()
.await
.map_err(|e| ServerFnError::new(e.to_string()))?;
let body: Body = super::agent_client::json_or_error(resp).await?;
Ok(body.data)
}
/// A stored archive's password state, as the target editor shows it.
@@ -233,10 +442,21 @@ pub fn demo_seed_default_selection(targets: &[DemoSeedTarget], source_only: bool
pub fn is_file_kind(kind: &str) -> bool {
matches!(
kind,
"plc_project" | "firmware_image" | "source_archive" | "mobile_package" | "build_output"
"plc_project"
| "firmware_image"
| "source_archive"
| "mobile_package"
| "build_output"
| "supplier_sbom"
)
}
/// Whether a file of `kind` may be a password-protected archive: firmware
/// images, build outputs and supplier SBOMs are never unpacked.
pub fn may_need_password(kind: &str) -> bool {
!matches!(kind, "firmware_image" | "build_output" | "supplier_sbom")
}
/// The PLC project format a file's name suggests, if any.
pub fn plc_format_for(file_name: &str) -> Option<&'static str> {
let name = file_name.to_ascii_lowercase();
@@ -303,9 +523,8 @@ pub fn validate_artifact_ref(kind: &str, source_ref: &str) -> Option<String> {
"container_image" => {
(!no_space).then(|| "Enter an image ref, e.g. registry/name:tag".to_string())
}
"source_archive" | "firmware_image" | "mobile_package" | "plc_project" | "build_output" => {
(!no_space).then(|| "Enter a path or URL (no spaces)".to_string())
}
"source_archive" | "firmware_image" | "mobile_package" | "plc_project" | "build_output"
| "supplier_sbom" => (!no_space).then(|| "Enter a path or URL (no spaces)".to_string()),
// plaintext_description (and anything unknown): accept free-form text.
_ => None,
}
@@ -415,12 +634,14 @@ pub async fn create_target(
target_type: String,
description: Option<String>,
artifacts: Vec<ArtifactInputDto>,
supplier: Option<SupplierDto>,
) -> Result<TargetResponse, ServerFnError> {
let body = serde_json::json!({
"name": name,
"target_type": target_type,
"description": description,
"artifacts": artifacts,
"supplier": supplier,
});
let resp = super::agent_client::agent_request(reqwest::Method::POST, "/api/v1/targets")
.await?
@@ -449,6 +670,7 @@ pub async fn upload_target_artifact(
file: dioxus::fullstack::FileStream,
) -> Result<TargetResponse, ServerFnError> {
let filename = file.file_name().to_string();
let sbom = kind == "supplier_sbom";
let part =
reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(file)).file_name(filename);
let mut form = reqwest::multipart::Form::new()
@@ -468,17 +690,21 @@ pub async fn upload_target_artifact(
.map_err(|e| ServerFnError::new(e.to_string()))?;
if !resp.status().is_success() {
return Err(ServerFnError::new(match resp.status().as_u16() {
// A supplier SBOM has its own, smaller limit.
413 if sbom => format!("{SBOM_REFUSED}too_large"),
413 => "file is larger than the 512 MiB upload limit".to_string(),
415 => UNSUPPORTED_ARCHIVE.to_string(),
422 => format!("{SBOM_REFUSED}{}", refusal_code(resp).await),
code => format!("upload rejected by the agent ({code})"),
}));
}
super::agent_client::json_or_error(resp).await
}
/// Update a target's name / type / artifacts / excluded paths (dashboard
/// editor). `exclude_paths` replaces the stored list; the agent normalises
/// and checks it (`normalise_exclude_paths`).
/// Update a target's name / type / artifacts / excluded paths / supplier
/// (dashboard editor). `exclude_paths` replaces the stored list; the agent
/// normalises and checks it (`normalise_exclude_paths`). A supplier with an
/// empty name removes it.
#[server]
pub async fn update_target(
id: String,
@@ -486,8 +712,15 @@ pub async fn update_target(
target_type: Option<String>,
artifacts: Option<Vec<ArtifactInputDto>>,
exclude_paths: Option<Vec<String>>,
supplier: Option<SupplierDto>,
) -> Result<TargetResponse, ServerFnError> {
let mut body = serde_json::Map::new();
if let Some(s) = supplier {
body.insert(
"supplier".to_string(),
serde_json::to_value(s).map_err(|e| ServerFnError::new(e.to_string()))?,
);
}
if let Some(n) = name {
body.insert("name".to_string(), serde_json::json!(n));
}
@@ -660,6 +893,80 @@ pub async fn trigger_target_scan(id: String) -> Result<serde_json::Value, Server
#[cfg(test)]
mod tests {
#[test]
fn a_supplier_is_sent_without_blank_fields_and_checked_as_the_agent_does() {
use super::SupplierDto;
let s = SupplierDto::from_fields(" Example GmbH ", "Drive Control", " ", "");
assert_eq!(s.name, "Example GmbH");
assert_eq!(s.product.as_deref(), Some("Drive Control"));
assert_eq!(s.version, None);
assert_eq!(
serde_json::to_value(&s).unwrap()["csaf_provider"],
serde_json::Value::Null
);
assert!(!SupplierDto::provider_is_invalid(""));
assert!(!SupplierDto::provider_is_invalid(
"https://psirt.example/provider-metadata.json"
));
assert!(SupplierDto::provider_is_invalid(
"http://psirt.example/x.json"
));
assert!(SupplierDto::provider_is_invalid(
"https://psirt.example/a b.json"
));
}
#[test]
fn an_uploaded_supplier_sbom_shows_what_its_upload_kept() {
use super::{agent_time, SbomSummary};
let artifact = serde_json::json!({
"detected": [
{ "key": "sbom_format", "value": "CycloneDX 1.5", "source": "upload" },
{ "key": "sbom_components", "value": "212", "source": "upload" },
{ "key": "sbom_statements", "value": "9", "source": "upload" },
],
"ingested_at": { "$date": { "$numberLong": "1794902428827" } },
});
assert_eq!(
SbomSummary::of(&artifact),
Some(SbomSummary {
format: "CycloneDX 1.5".into(),
components: 212,
statements: 9
})
);
// One uploaded before the summary was kept shows without it.
assert_eq!(
SbomSummary::of(&serde_json::json!({ "detected": [] })),
None
);
assert_eq!(
agent_time(&artifact["ingested_at"]).map(|t| t.timestamp_millis()),
Some(1_794_902_428_827)
);
assert!(agent_time(&serde_json::json!("2026-11-17T08:00:00Z")).is_some());
assert_eq!(agent_time(&serde_json::Value::Null), None);
}
#[test]
fn a_refused_supplier_sbom_keeps_its_code_through_the_server_function() {
use super::sbom_refusal_code;
assert_eq!(
sbom_refusal_code("error running server function: supplier_sbom_refused:empty"),
Some("empty")
);
// However the error is wrapped, only the code is taken.
assert_eq!(
sbom_refusal_code(r#"ServerError("supplier_sbom_refused:unknown_format")"#),
Some("unknown_format")
);
assert_eq!(sbom_refusal_code("supplier_sbom_refused:"), None);
assert_eq!(
sbom_refusal_code("upload rejected by the agent (500)"),
None
);
}
#[test]
fn a_plc_file_name_suggests_its_format() {
assert_eq!(
+251 -28
View File
@@ -14,12 +14,13 @@ 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};
use crate::i18n::{format_bytes, use_lang, Lang};
use crate::infrastructure::onboarding::{
create_target, detect_target, enable_target_scans, fetch_applicable_scans, is_file_kind,
plc_format_for, set_archive_password, trigger_new_content_scan, upload_target_artifact,
validate_artifact_ref, validate_target_name, ArchivePassword, ArtifactInputDto,
PasswordOutcome, UNSUPPORTED_ARCHIVE,
check_supplier_sbom, create_target, detect_target, enable_target_scans, fetch_applicable_scans,
is_file_kind, may_need_password, plc_format_for, set_archive_password,
trigger_new_content_scan, upload_problem, upload_target_artifact, validate_artifact_ref,
validate_target_name, ArchivePassword, ArtifactInputDto, PasswordOutcome, SbomCheck,
SbomSummary, SupplierDto,
};
use crate::infrastructure::platform::{use_source_only, SourceOnlyNote};
@@ -29,11 +30,29 @@ fn is_runtime_kind(kind: &str) -> bool {
matches!(kind, "live_url")
}
/// What the agent said of a staged supplier SBOM (#1025), checked when it is
/// added so a file a scan cannot read is refused before the target exists.
#[derive(Debug, Clone, PartialEq)]
enum StagedCheck {
/// Not a supplier SBOM: nothing to check.
None,
/// The agent is reading it.
Checking,
/// A scan can read it.
Readable(SbomSummary),
/// Refused; the text says why.
Refused(String),
}
/// A file staged in the wizard. It holds the browser's file handle, not its
/// contents: the file is streamed straight from disk when it is uploaded, so a
/// 500 MB firmware image is never copied into WASM memory.
#[derive(Clone)]
struct PendingFile {
/// Which staged file this is, for the check's answer to find it.
id: usize,
/// The supplier SBOM check.
check: StagedCheck,
kind: String,
plc_format: Option<String>,
filename: String,
@@ -96,6 +115,13 @@ pub fn OnboardingPage() -> Element {
let mut new_plc_format = use_signal(|| "plcopen_xml".to_string());
let mut new_file = use_signal(|| Option::<(String, dioxus::html::FileData)>::None);
let mut pending_files = use_signal(Vec::<PendingFile>::new);
let mut staged_count = use_signal(|| 0usize);
// A bought-in component and its supplier (#1025).
let mut bought = use_signal(|| false);
let mut sup_name = use_signal(String::new);
let mut sup_product = use_signal(String::new);
let mut sup_version = use_signal(String::new);
let mut sup_csaf = use_signal(String::new);
// Create + result state.
let mut creating = use_signal(|| false);
@@ -113,8 +139,38 @@ pub fn OnboardingPage() -> Element {
let source_only = use_source_only();
let step_now = step();
let name_error = validate_target_name(&name());
let can_advance_type = name_error.is_none() && !target_type().trim().is_empty();
let has_artifacts = !artifacts().is_empty() || !pending_files().is_empty();
let csaf_invalid = SupplierDto::provider_is_invalid(&sup_csaf());
let supplier_ok = !bought() || (!sup_name().trim().is_empty() && !csaf_invalid);
let can_advance_type = name_error.is_none() && !target_type().trim().is_empty() && supplier_ok;
let supplier = bought().then(|| {
SupplierDto::from_fields(&sup_name(), &sup_product(), &sup_version(), &sup_csaf())
});
// A refused file is not uploaded; one still being read holds "Next".
let usable_files = pending_files()
.iter()
.filter(|f| !matches!(f.check, StagedCheck::Refused(_)))
.count();
let checking = pending_files()
.iter()
.any(|f| f.check == StagedCheck::Checking);
let has_artifacts = !artifacts().is_empty() || usable_files > 0;
// After the first step, the header says what is being onboarded.
let context = {
let mut parts = vec![name(), type_label_of(&target_type(), lang)];
if let Some(s) = supplier.as_ref().filter(|s| !s.name.is_empty()) {
parts.push(format!("{} {}", tx::FROM.get(lang), s.name));
}
parts.retain(|p| !p.is_empty());
parts.join(" · ")
};
// A bought-in component's SBOM first.
let artifact_kinds: Vec<(&'static str, crate::i18n::Text)> = {
let mut list = kinds::ARTIFACT_KINDS.to_vec();
if bought() {
list.sort_by_key(|(v, _)| *v != "supplier_sbom");
}
list
};
let optin = if source_only {
Vec::new()
} else {
@@ -126,7 +182,7 @@ pub fn OnboardingPage() -> Element {
} else {
validate_artifact_ref(&new_kind(), &new_source())
};
let type_label = move |value: &str| kinds::target_type(value, lang);
let type_label = move |value: &str| type_label_of(value, lang);
let kind_label = move |value: &str| kinds::artifact_kind(value, lang);
// Adding a target is a change: a read-only role only reads why not.
@@ -143,14 +199,21 @@ pub fn OnboardingPage() -> Element {
rsx! {
PageHeader {
title: tx::TITLE.get(lang),
description: tx::SUBTITLE.get(lang),
description: if step_now == 0 { tx::SUBTITLE.get(lang).to_string() } else { context.clone() },
}
// Stepper.
div { class: "wizard-steps",
for (i, label) in tx::STEPS.iter().enumerate() {
div {
class: if i == step_now { "wizard-step wizard-step-active" } else { "wizard-step" },
class: if i == step_now {
"wizard-step active"
} else if i < step_now {
"wizard-step completed"
} else {
"wizard-step"
},
"aria-current": if i == step_now { "step" } else { "false" },
span { class: "wizard-step-dot", "{i + 1}" }
span { class: "wizard-step-label", {label.get(lang)} }
}
@@ -188,6 +251,85 @@ pub fn OnboardingPage() -> Element {
span { {tx::DEMO_PROMPT.get(lang)} }
DemoTargetsButton { secondary: true }
}
h4 { class: "type-group-label",
{tx::ORIGIN.get(lang)}
" "
span { class: "badge badge-new", {tx::NEW.get(lang)} }
}
div { class: "origin-grid",
for (is_bought, title, hint) in [
(false, tx::ORIGIN_OWN, tx::ORIGIN_OWN_HINT),
(true, tx::ORIGIN_BOUGHT, tx::ORIGIN_BOUGHT_HINT),
] {
button {
r#type: "button",
class: "type-card",
"aria-pressed": if bought() == is_bought { "true" } else { "false" },
onclick: move |_| {
bought.set(is_bought);
// The SBOM is what a bought-in component brings.
if is_bought {
new_kind.set("supplier_sbom".to_string());
} else if new_kind() == "supplier_sbom" {
new_kind.set("git_repo".to_string());
}
},
span { class: "type-card-name", {title.get(lang)} }
span { class: "type-card-hint", {hint.get(lang)} }
}
}
}
if bought() {
div { class: "supplier-box",
h4 { class: "type-group-label supplier-box-title", {tx::SUPPLIER.get(lang)} }
div { class: "supplier-grid",
div { class: "form-group",
label { r#for: "sup-name", {tx::SUPPLIER.get(lang)} }
input {
id: "sup-name",
r#type: "text",
value: "{sup_name}",
oninput: move |e| sup_name.set(e.value()),
}
}
div { class: "supplier-grid",
div { class: "form-group",
label { r#for: "sup-product", {tx::PRODUCT.get(lang)} }
input {
id: "sup-product",
r#type: "text",
value: "{sup_product}",
oninput: move |e| sup_product.set(e.value()),
}
}
div { class: "form-group",
label { r#for: "sup-version", {tx::VERSION.get(lang)} }
input {
id: "sup-version",
r#type: "text",
value: "{sup_version}",
oninput: move |e| sup_version.set(e.value()),
}
}
}
}
div { class: "form-group",
label { r#for: "sup-csaf", {tx::CSAF_OPTIONAL.get(lang)} }
input {
id: "sup-csaf",
r#type: "url",
placeholder: "https://…/.well-known/csaf/provider-metadata.json",
value: "{sup_csaf}",
oninput: move |e| sup_csaf.set(e.value()),
}
if csaf_invalid {
div { class: "form-error", {tx::CSAF_HTTPS.get(lang)} }
}
div { class: "form-hint", {tx::CSAF_HINT.get(lang)} }
}
div { class: "form-hint", {tx::PRODUCT_HINT.get(lang)} }
}
}
for (group, range) in [
(tx::GROUP_MACHINE, 0..kinds::MACHINE_TYPES),
(tx::GROUP_SOFTWARE, kinds::MACHINE_TYPES..kinds::TARGET_TYPES.len()),
@@ -225,6 +367,12 @@ pub fn OnboardingPage() -> Element {
// ---- Step 1: artifacts ----
if step_now == 1 {
div { class: "card-header", {tx::ATTACH.get(lang)} }
if bought() {
div { class: "callout-accent",
div { style: "font-weight: 600; margin-bottom: 2px;", {tx::BOUGHT_TITLE.get(lang)} }
{tx::BOUGHT_HINT.get(lang)}
}
}
if target_type() == "plc_sps" {
div {
style: "margin: 12px 16px 0; padding: 12px 14px; border-left: 3px solid var(--accent, #3b82f6); background: var(--surface-2, rgba(59,130,246,0.08)); font-size: 0.88em; line-height: 1.55;",
@@ -239,7 +387,7 @@ pub fn OnboardingPage() -> Element {
select {
value: "{new_kind}",
oninput: move |e| new_kind.set(e.value()),
for (value, klabel) in kinds::ARTIFACT_KINDS {
for (value, klabel) in artifact_kinds.iter().copied() {
if source_only && is_runtime_kind(value) {
option { value: "{value}", disabled: true, title: common::NOT_AVAILABLE_HERE.get(lang),
"{klabel.get(lang)} — {common::NOT_AVAILABLE_HERE.get(lang)}"
@@ -303,7 +451,30 @@ pub fn OnboardingPage() -> Element {
} else {
None
};
let id = staged_count();
staged_count.set(id + 1);
let sbom = kind == "supplier_sbom";
if sbom {
let file = data.clone();
spawn(async move {
let check = match check_supplier_sbom(file.into()).await {
Ok(SbomCheck::Readable(summary)) => StagedCheck::Readable(summary),
Ok(SbomCheck::Refused(code)) => StagedCheck::Refused(format!(
"{}: {}",
tx::REFUSED.get(lang),
tx::sbom_refusal(&code, lang)
)),
// Not checked: the upload checks it again.
Err(_) => StagedCheck::None,
};
if let Some(f) = pending_files.write().iter_mut().find(|f| f.id == id) {
f.check = check;
}
});
}
pending_files.write().push(PendingFile {
id,
check: if sbom { StagedCheck::Checking } else { StagedCheck::None },
kind,
plc_format,
filename: fname,
@@ -400,14 +571,31 @@ pub fn OnboardingPage() -> Element {
// Staged file artifacts (uploaded after the target is created).
for (i, pf) in pending_files().iter().enumerate() {
div {
style: "display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border: 1px solid var(--border, #333); border-radius: 6px; margin-top: 6px;",
span {
span { style: "opacity: 0.7;", "{kind_label(&pf.kind)} ({tx::FILE_SUFFIX.get(lang)}): " }
"{pf.filename} ({format_bytes(pf.file.size(), lang)})"
class: if matches!(pf.check, StagedCheck::Refused(_)) { "staged-file is-refused" } else { "staged-file" },
div { class: "staged-file-name",
span {
span { style: "opacity: 0.7;", "{kind_label(&pf.kind)} ({tx::FILE_SUFFIX.get(lang)}): " }
span { style: "font-family: var(--font-mono);", "{pf.filename}" }
" ({format_bytes(pf.file.size(), lang)})"
}
match &pf.check {
StagedCheck::None => rsx! {},
StagedCheck::Checking => rsx! {
span { class: "target-muted", {tx::SBOM_CHECKING.get(lang)} }
},
StagedCheck::Readable(summary) => rsx! {
span { class: "badge badge-accent",
{tx::sbom_summary(&summary.format, summary.components, summary.statements, lang)}
}
},
StagedCheck::Refused(why) => rsx! {
span { class: "staged-file-refusal", "{why}" }
},
}
}
// Firmware images and build outputs are never unpacked;
// archives may be locked.
if pf.kind != "firmware_image" && pf.kind != "build_output" {
// Firmware images, build outputs and SBOMs are never
// unpacked; archives may be locked.
if may_need_password(&pf.kind) {
input {
r#type: "password",
autocomplete: "off",
@@ -425,6 +613,9 @@ pub fn OnboardingPage() -> Element {
}
}
if new_kind() == "supplier_sbom" {
div { class: "form-hint", style: "margin-top: 8px;", {tx::SBOM_READ_ON_ADD.get(lang)} }
}
div { style: "margin-top: 16px;",
if has_artifacts {
for (i, a) in artifacts().iter().enumerate() {
@@ -458,6 +649,14 @@ pub fn OnboardingPage() -> Element {
div { class: "wizard-summary",
div { strong { "{tx::NAME.get(lang)}: " } "{name()}" }
div { strong { "{tx::TYPE.get(lang)}: " } "{type_label(&target_type())}" }
if let Some(s) = supplier.clone() {
div {
strong { "{tx::SUPPLIER.get(lang)}: " }
"{s.name}"
if let Some(p) = s.product.as_ref() { " · {p}" }
if let Some(v) = s.version.as_ref() { " {v}" }
}
}
div { strong { "{tx::ARTIFACTS.get(lang)}:" } }
ul {
for a in artifacts() {
@@ -466,7 +665,7 @@ pub fn OnboardingPage() -> Element {
if a.has_token { " ({tx::TOKEN_SET.get(lang)})" }
}
}
for pf in pending_files() {
for pf in pending_files().into_iter().filter(|f| !matches!(f.check, StagedCheck::Refused(_))) {
li { "{kind_label(&pf.kind)}: {pf.filename} ({format_bytes(pf.file.size(), lang)})" }
}
}
@@ -620,6 +819,11 @@ pub fn OnboardingPage() -> Element {
artifacts.write().clear();
pending_files.write().clear();
new_file.set(None);
bought.set(false);
sup_name.set(String::new());
sup_product.set(String::new());
sup_version.set(String::new());
sup_csaf.set(String::new());
scans.write().clear();
suggested.set(None);
created_id.set(None);
@@ -647,7 +851,7 @@ pub fn OnboardingPage() -> Element {
if step_now < 2 {
button {
class: "btn btn-primary",
disabled: (step_now == 0 && !can_advance_type) || (step_now == 1 && !has_artifacts),
disabled: (step_now == 0 && !can_advance_type) || (step_now == 1 && (!has_artifacts || checking)),
onclick: move |_| step.set(step() + 1),
{tx::NEXT.get(lang)}
}
@@ -659,12 +863,17 @@ pub fn OnboardingPage() -> Element {
let n = name();
let tt = target_type();
let arts = artifacts();
let files = pending_files();
// A refused SBOM is not uploaded.
let files: Vec<PendingFile> = pending_files()
.into_iter()
.filter(|f| !matches!(f.check, StagedCheck::Refused(_)))
.collect();
let sup = supplier.clone();
creating.set(true);
error.set(None);
upload_errors.write().clear();
spawn(async move {
let id = match create_target(n, tt, None, arts).await {
let id = match create_target(n, tt, None, arts, sup).await {
Ok(resp) => resp
.data
.get("_id")
@@ -696,12 +905,7 @@ pub fn OnboardingPage() -> Element {
.await
{
Err(e) => {
let e = e.to_string();
let msg = if e.contains(UNSUPPORTED_ARCHIVE) {
common::UNSUPPORTED_ARCHIVE.get(lang).to_string()
} else {
e
};
let msg = upload_problem(e.to_string(), lang);
upload_errors.write().push(format!("{fname}: {msg}"));
}
// A locked archive: store its password, or ask
@@ -767,10 +971,29 @@ pub fn OnboardingPage() -> Element {
}
}
/// A target type's label; none chosen yet is empty.
fn type_label_of(value: &str, lang: Lang) -> String {
if value.is_empty() {
String::new()
} else {
kinds::target_type(value, lang)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn a_refused_supplier_sbom_upload_reads_in_the_readers_language() {
let error = "error running server function: supplier_sbom_refused:empty (details: None)";
assert_eq!(
upload_problem(error.to_string(), Lang::De),
format!("Abgelehnt: {}", tx::sbom_refusal("empty", Lang::De))
);
assert_eq!(upload_problem("boom".to_string(), Lang::En), "boom");
}
#[test]
fn only_unblocked_default_off_scans_are_opt_in() {
let scans = vec![
+152 -7
View File
@@ -22,16 +22,18 @@ use crate::components::severity_badge::SeverityBadge;
use crate::components::toast::{ToastType, Toasts};
use crate::components::webhook_deliveries::WebhookDeliveries;
use crate::i18n::texts::{
common, compliance::language_name, kinds, repo_views as rv, targets as tx,
common, compliance::language_name, kinds, onboarding as onboarding_tx, repo_views as rv,
targets as tx,
};
use crate::i18n::use_lang;
use crate::i18n::{format_ago, use_lang};
use crate::infrastructure::evidence::{fetch_compliance, CraCounts};
use crate::infrastructure::findings::{fetch_findings, location, FindingsQuery};
use crate::infrastructure::graph::fetch_graph_summary;
use crate::infrastructure::onboarding::{
delete_target, fetch_applicable_scans, fetch_target, is_file_kind, set_archive_password,
trigger_target_scan, update_target, validate_artifact_ref, validate_target_name,
ArchivePassword, ArtifactInputDto, PasswordOutcome,
agent_time, delete_target, fetch_applicable_scans, fetch_supplier_advisories, fetch_target,
is_file_kind, set_archive_password, trigger_target_scan, update_target, validate_artifact_ref,
validate_target_name, ArchivePassword, ArtifactInputDto, PasswordOutcome, SbomSummary,
SupplierDto,
};
use crate::infrastructure::platform::{use_source_only, SourceOnlyNote};
use crate::infrastructure::projects::{
@@ -90,6 +92,8 @@ fn editable_artifacts(target: &serde_json::Value) -> Vec<ArtifactInputDto> {
== Some("token"),
artifact_id: str_at(a, "id").to_string(),
archive_password: ArchivePassword::of(a),
sbom: SbomSummary::of(a),
uploaded_at: agent_time(&a["ingested_at"]),
..Default::default()
})
.collect()
@@ -188,6 +192,9 @@ pub fn TargetPage(id: String) -> Element {
}
p { class: "target-head-meta",
span { "{type_label}" }
if let Some(s) = SupplierDto::of(&t) {
span { "{onboarding_tx::FROM.get(lang)} {s.name}" }
}
if kinds::is_preview(str_at(&t, "target_type")) {
span { class: "badge badge-medium", title: "{kinds::PREVIEW_NOTE.get(lang)}",
{kinds::PREVIEW.get(lang)}
@@ -553,6 +560,17 @@ fn TargetEditor(
let stored_projects = project_ids_of(&target);
let edit_projects = use_signal(|| stored_projects.clone());
let projects = use_resource(fetch_projects);
// The supplier of a bought-in component (#1025); saved only when changed.
let stored_supplier = SupplierDto::of(&target).unwrap_or_default();
let mut sup_name = use_signal(|| stored_supplier.name.clone());
let mut sup_product = use_signal(|| stored_supplier.product.clone().unwrap_or_default());
let mut sup_version = use_signal(|| stored_supplier.version.clone().unwrap_or_default());
let mut sup_csaf = use_signal(|| stored_supplier.csaf_provider.clone().unwrap_or_default());
let eid_advisories = eid.clone();
let advisories = use_resource(move || {
let id = eid_advisories.clone();
async move { fetch_supplier_advisories(id).await.ok().flatten() }
});
// The dialog's "add artifact" row.
let mut e_kind = use_signal(|| "git_repo".to_string());
let mut e_source = use_signal(String::new);
@@ -571,6 +589,19 @@ fn TargetEditor(
} else {
validate_artifact_ref(&e_kind(), &e_source())
};
let csaf_invalid = SupplierDto::provider_is_invalid(&sup_csaf());
let supplier =
SupplierDto::from_fields(&sup_name(), &sup_product(), &sup_version(), &sup_csaf());
let supplier_changed = supplier != stored_supplier;
let provider_saved = stored_supplier.csaf_provider.is_some()
&& supplier.csaf_provider == stored_supplier.csaf_provider;
let has_supplier_sbom = edit_arts().iter().any(|a| a.kind == "supplier_sbom");
// A bought-in component's file is most often its SBOM.
let upload_kind: &'static str = if stored_supplier.name.is_empty() {
"source_archive"
} else {
"supplier_sbom"
};
rsx! {
div { class: "modal-overlay",
div { class: "modal-dialog modal-wide form-fields",
@@ -609,6 +640,62 @@ fn TargetEditor(
}
}
}
div { class: "modal-section",
h4 { class: "target-subhead",
{tx::SUPPLIER_SECTION.get(lang)}
" "
span { class: "badge badge-new", {onboarding_tx::NEW.get(lang)} }
}
div { class: "supplier-grid",
div { class: "form-group",
label { r#for: "edit-sup-name", {onboarding_tx::SUPPLIER.get(lang)} }
input {
id: "edit-sup-name",
r#type: "text",
value: "{sup_name}",
oninput: move |e| sup_name.set(e.value()),
}
}
div { class: "supplier-grid",
div { class: "form-group",
label { r#for: "edit-sup-product", {onboarding_tx::PRODUCT.get(lang)} }
input {
id: "edit-sup-product",
r#type: "text",
value: "{sup_product}",
oninput: move |e| sup_product.set(e.value()),
}
}
div { class: "form-group",
label { r#for: "edit-sup-version", {onboarding_tx::VERSION.get(lang)} }
input {
id: "edit-sup-version",
r#type: "text",
value: "{sup_version}",
oninput: move |e| sup_version.set(e.value()),
}
}
}
}
div { class: "form-group",
label { r#for: "edit-sup-csaf", {tx::SUPPLIER_CSAF.get(lang)} }
input {
id: "edit-sup-csaf",
r#type: "url",
placeholder: "https://…/.well-known/csaf/provider-metadata.json",
value: "{sup_csaf}",
oninput: move |e| sup_csaf.set(e.value()),
}
if csaf_invalid {
div { class: "form-error", {onboarding_tx::CSAF_HTTPS.get(lang)} }
} else if provider_saved {
SupplierAdvisoriesStatus { status: advisories.read().clone().flatten() }
} else if supplier.csaf_provider.is_some() {
div { class: "form-hint", {tx::ADVISORIES_READ_AFTER_SAVE.get(lang)} }
}
}
div { class: "form-hint", {tx::SUPPLIER_EDIT_HINT.get(lang)} }
}
div { class: "modal-section",
h4 { class: "target-subhead", {tx::ARTIFACTS.get(lang)} }
for (i, a) in edit_arts().iter().enumerate() {
@@ -616,6 +703,15 @@ fn TargetEditor(
span { class: "artifact-row-ref",
span { style: "opacity: 0.7;", "{kinds::artifact_kind(&a.kind, lang)}: " }
span { style: "font-family: monospace;", "{a.source_ref}" }
if a.kind == "supplier_sbom" && (a.sbom.is_some() || a.uploaded_at.is_some()) {
span { class: "artifact-row-facts",
{tx::sbom_facts(
a.sbom.as_ref().map(|s| (s.format.as_str(), s.components, s.statements)),
a.uploaded_at.map(|t| upload_date(&t, lang)).as_deref(),
lang,
)}
}
}
if a.token.as_deref() == Some("") {
span { class: "badge badge-medium", style: "margin-left: 6px;", {tx::TOKEN_REMOVED.get(lang)} }
} else if a.has_token {
@@ -655,6 +751,9 @@ fn TargetEditor(
}
}
}
if has_supplier_sbom {
div { class: "form-hint", {tx::SBOM_REPLACES.get(lang)} }
}
div { class: "artifact-add",
div { class: "form-group artifact-add-kind",
label { {tx::KIND.get(lang)} }
@@ -729,6 +828,7 @@ fn TargetEditor(
h4 { class: "target-subhead", {tx::UPLOAD_TITLE.get(lang)} }
ArtifactUpload {
target_id: eid.clone(),
kind: upload_kind,
// The editor's artifact list is now stale: saving it
// would drop the new file, so close and reload.
on_uploaded: move |_| {
@@ -771,7 +871,7 @@ fn TargetEditor(
}
button {
class: "btn btn-primary",
disabled: edit_saving() || name_err.is_some() || exclude_err.is_some(),
disabled: edit_saving() || name_err.is_some() || exclude_err.is_some() || csaf_invalid,
onclick: move |_| {
let id = eid.clone();
let nm = edit_name();
@@ -780,9 +880,10 @@ fn TargetEditor(
let excluded = exclude_paths.clone();
let chosen = edit_projects();
let projects_changed = chosen != stored_projects;
let sup = supplier_changed.then(|| supplier.clone());
edit_saving.set(true);
spawn(async move {
let saved = match update_target(id.clone(), Some(nm), Some(tt), Some(arts), Some(excluded)).await {
let saved = match update_target(id.clone(), Some(nm), Some(tt), Some(arts), Some(excluded), sup).await {
Ok(_) if projects_changed => set_target_projects(id, chosen).await,
Ok(_) => Ok(()),
Err(e) => Err(e),
@@ -806,6 +907,50 @@ fn TargetEditor(
}
}
/// An upload's date in the reader's convention: `16.11.2026`, `2026-11-16`.
fn upload_date(time: &chrono::DateTime<chrono::Utc>, lang: crate::i18n::Lang) -> String {
match lang {
crate::i18n::Lang::De => time.format("%d.%m.%Y").to_string(),
crate::i18n::Lang::En => time.format("%Y-%m-%d").to_string(),
}
}
/// How many of the supplier's advisories are kept, and when its provider was
/// last read: not yet, unreachable, or the count (#1025).
#[component]
fn SupplierAdvisoriesStatus(
status: Option<crate::infrastructure::onboarding::SupplierAdvisoriesDto>,
) -> Element {
let lang = use_lang()();
let now = chrono::Utc::now();
let checked = status
.as_ref()
.and_then(|s| s.checked_at)
.map(|t| tx::advisories_checked(&format_ago(&t, &now, lang), lang));
let (class, label) = match &status {
Some(s) if s.reachable == Some(false) => (
"badge badge-danger",
tx::ADVISORIES_UNREACHABLE.get(lang).to_string(),
),
Some(s) if s.checked_at.is_some() => (
"badge badge-success",
tx::advisories_read(s.advisories, lang),
),
_ => (
"badge badge-neutral",
tx::ADVISORIES_NOT_READ.get(lang).to_string(),
),
};
rsx! {
div { class: "supplier-advisories",
span { class, "{label}" }
if let Some(checked) = checked {
span { class: "form-hint", "{checked}" }
}
}
}
}
/// The password of a stored, password-protected archive: its state, and a
/// field that checks and saves a new one at once (not with the editor's Save,
/// which never carries credentials).
+9
View File
@@ -95,6 +95,15 @@ then checked for known vulnerabilities like those read from code: OSV, NVD, the
CISA KEV list and EPSS, and the vendor advisories (CSAF) by purl. The results
go through the same CVE groups, VEX statements and ENISA drafts.
In the dashboard, choose **Von einem Zulieferer gekauft** in the wizard's
first step, name the supplier (and, optionally, its product, version and CSAF
provider), then add the SBOM as **Zulieferer-SBOM**. The wizard reads it as it
is added and refuses one a scan could not read. The target editor shows the
supplier, how many of its advisories were read, and what the uploaded SBOM
holds. In **CVEs & VEX**, a **Lieferant sagt** column shows the supplier's
statement next to yours. **In meine Aussage übernehmen** copies it into your
form, and it is stored only when you save it as your own statement.
- **Formats:** CycloneDX 1.4 to 1.6 (JSON or XML) and SPDX 2.3 JSON. SPDX 3.0
is not read yet.
- **What is read of each component:** name (with its group), version, purl,