Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbc1ba0362 | ||
|
|
ade1191070 | ||
|
|
9119dcdd9d | ||
|
|
87b1e281ed | ||
|
|
ddb0068b3e |
No files matched your search
Generated
+6
-6
@@ -959,9 +959,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cookie"
|
||||
version = "0.18.1"
|
||||
version = "0.18.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747"
|
||||
checksum = "d55f2d6c30eeec7d5c6f98bd4395d4abb1895629eab97ee6522d340623615f8a"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"hmac 0.12.1",
|
||||
@@ -2292,9 +2292,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.2.2"
|
||||
version = "1.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
|
||||
checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e"
|
||||
dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
@@ -6784,9 +6784,9 @@ checksum = "e497bb1f828cc9fb236722c2eaa100dcf201563f38f4da6252357a59037adf31"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.5.8"
|
||||
version = "2.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
|
||||
checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
|
||||
@@ -20,7 +20,8 @@ use super::dto::{collect_cursor_async, tenant_db, AgentExt, ApiResponse, ApiResu
|
||||
use super::findings::Actor;
|
||||
|
||||
/// GET /api/v1/targets/{id}/cves — the target's CVE alerts with their VEX
|
||||
/// statements, newest first.
|
||||
/// statements, newest first. A `fixed` a scan inferred from a CVE no longer
|
||||
/// being found is left out (#994).
|
||||
#[tracing::instrument(skip_all, fields(target_id = %id))]
|
||||
pub async fn list_target_cves(
|
||||
Extension(agent): AgentExt,
|
||||
@@ -29,7 +30,8 @@ pub async fn list_target_cves(
|
||||
) -> ApiResult<Vec<CveAlert>> {
|
||||
let db = tenant_db(&agent, &tenant).await?;
|
||||
// An unreadable list reads as empty here, as it always has.
|
||||
let alerts = target_alerts(&db, &id).await.unwrap_or_default();
|
||||
let mut alerts = target_alerts(&db, &id).await.unwrap_or_default();
|
||||
alerts.iter_mut().for_each(CveAlert::drop_inferred_fix);
|
||||
Ok(Json(ApiResponse {
|
||||
total: Some(alerts.len() as u64),
|
||||
data: alerts,
|
||||
|
||||
@@ -349,7 +349,7 @@ fn json<T: Serialize>(value: &T) -> Result<Vec<u8>, AgentError> {
|
||||
/// The findings as CSV, one row each, for a spreadsheet.
|
||||
fn findings_csv(findings: &[Finding]) -> String {
|
||||
let mut out =
|
||||
String::from("id,severity,status,type,scanner,rule_id,cwe,location,title,cra_controls\n");
|
||||
String::from("id,severity,status,type,scanner,rule_id,cwe,location,title,cra_controls,cra_requirements\n");
|
||||
for f in findings {
|
||||
let location = match (&f.file_path, f.line_number) {
|
||||
(Some(file), Some(line)) => format!("{file}:{line}"),
|
||||
@@ -367,6 +367,13 @@ fn findings_csv(findings: &[Finding]) -> String {
|
||||
location,
|
||||
f.title.clone(),
|
||||
f.control_refs.join(" "),
|
||||
// The same requirements by name, for a person reading the sheet.
|
||||
f.control_refs
|
||||
.iter()
|
||||
.filter_map(|id| compliance_core::cra_requirements::name(id))
|
||||
.map(|name| name.de)
|
||||
.collect::<Vec<_>>()
|
||||
.join("; "),
|
||||
];
|
||||
let cells: Vec<String> = row.iter().map(|c| csv_cell(c)).collect();
|
||||
out.push_str(&cells.join(","));
|
||||
@@ -636,6 +643,10 @@ mod tests {
|
||||
"{csv}"
|
||||
);
|
||||
assert!(csv.contains("Core/Src/comms.c:9"));
|
||||
assert!(
|
||||
csv.contains(",cra-ai-8,Keine Standardpasswörter\n"),
|
||||
"{csv}"
|
||||
);
|
||||
assert_eq!(csv_cell("=HYPERLINK(1)"), "'=HYPERLINK(1)");
|
||||
assert_eq!(csv_cell("plain"), "plain");
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
//! For a target from a managed git source (#439), every critical or high CVE
|
||||
//! in its components becomes one issue per package and CVE, labelled like the
|
||||
//! finding issues plus `cve`, with the fixed version where the advisory names
|
||||
//! one. When a later complete scan no longer finds the CVE (the dependency was
|
||||
//! updated or removed), the issue is closed with a comment; when it comes back,
|
||||
//! it is reopened.
|
||||
//! one. When a later complete scan no longer finds the CVE, the issue stays
|
||||
//! open and is told so once (#994): a CVE can disappear without a fix (other
|
||||
//! scan data, a changed identification), so a person checks and closes it.
|
||||
//! When the CVE comes back, the next disappearance is told again.
|
||||
//!
|
||||
//! An issue a person closed in Gitea (#953) stays closed while the scan still
|
||||
//! finds its CVE: closing it was that person's call, and no VEX statement is
|
||||
@@ -96,6 +97,8 @@ pub(crate) struct CveIssueCounts {
|
||||
pub created: u32,
|
||||
pub reopened: u32,
|
||||
pub closed: u32,
|
||||
/// Open issues told that the scan no longer finds their CVE.
|
||||
pub noted_gone: u32,
|
||||
}
|
||||
|
||||
/// The key a CVE issue is stored under (`TrackerIssue::finding_id`): one per
|
||||
@@ -165,7 +168,8 @@ fn issue_worthy(alert: &CveAlert, epss_percentile: Option<f64>) -> bool {
|
||||
/// its stored VEX statement
|
||||
/// ([`crate::pipeline::vex_lifecycle::attach_stored_vex`])
|
||||
/// * `complete` - whether every component was matched; only then is a CVE
|
||||
/// that is missing from `alerts` known to be gone, and its issue closed
|
||||
/// that is missing from `alerts` known to be gone, and its open issue told
|
||||
/// so (once; it stays open)
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
@@ -203,6 +207,11 @@ pub(crate) async fn sync_cve_issues(
|
||||
match existing.get(key) {
|
||||
// A person closed it in Gitea while the CVE is unchanged.
|
||||
Some(issue) if issue.closed_in_tracker.is_some() => {}
|
||||
// Found again after it was gone: a later disappearance is told
|
||||
// again.
|
||||
Some(issue) if issue.gone_noted_at.is_some() && !issue.status.is_closed() => {
|
||||
note_gone(target.db, issue, false).await?;
|
||||
}
|
||||
Some(issue) if issue.status.is_closed() => {
|
||||
let comment = "**Prüfwerk:** Bei der Prüfung erneut gefunden, daher wieder geöffnet.\n\nFound again by the scan, so reopened.";
|
||||
if set_state(target, issue, comment, "open").await {
|
||||
@@ -242,10 +251,22 @@ pub(crate) async fn sync_cve_issues(
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let comment = "**Prüfwerk:** Die Prüfung findet diese Schwachstelle nicht mehr: Die Abhängigkeit wurde aktualisiert oder entfernt.\n\nThe scan no longer finds this vulnerability: the dependency was updated or removed.";
|
||||
if set_state(target, issue, comment, "closed").await {
|
||||
record(target.db, issue, IssueStatus::Closed).await?;
|
||||
counts.closed += 1;
|
||||
if issue.gone_noted_at.is_some() {
|
||||
continue;
|
||||
}
|
||||
let number = issue.external_id.as_str();
|
||||
match target
|
||||
.tracker
|
||||
.add_comment(target.owner, target.repo, number, GONE_COMMENT)
|
||||
.await
|
||||
{
|
||||
Ok(()) => {
|
||||
note_gone(target.db, issue, true).await?;
|
||||
counts.noted_gone += 1;
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!(issue = number, error = %e, "could not comment on the CVE issue");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -445,10 +466,6 @@ fn issue_body(alert: &CveAlert, severity: &str, target_id: &str, dashboard: &str
|
||||
.push_str("- Behoben in / Fixed in: keine Version bekannt / no fixed version known\n"),
|
||||
fixed => body.push_str(&format!("- Behoben in / Fixed in: {}\n", fixed.join(", "))),
|
||||
}
|
||||
body.push_str(&format!(
|
||||
"- Advisory: https://osv.dev/vulnerability/{}\n",
|
||||
alert.cve_id
|
||||
));
|
||||
if alert
|
||||
.exploitation
|
||||
.as_ref()
|
||||
@@ -460,14 +477,8 @@ fn issue_body(alert: &CveAlert, severity: &str, target_id: &str, dashboard: &str
|
||||
));
|
||||
}
|
||||
body.push_str("\n### CRA\n\n");
|
||||
let map = control_map::ControlMap::cra().ok();
|
||||
for id in CVE_CONTROLS {
|
||||
let title = map
|
||||
.as_ref()
|
||||
.and_then(|m| m.coverage(id))
|
||||
.map(|c| c.title.clone())
|
||||
.unwrap_or_default();
|
||||
body.push_str(&format!("- {id} — {title} (Annex I)\n"));
|
||||
for requirement in crate::pipeline::issue_creation::cra_requirements(&CVE_CONTROLS) {
|
||||
body.push_str(&format!("- {requirement}\n"));
|
||||
}
|
||||
let dashboard = dashboard.trim_end_matches('/');
|
||||
if dashboard.starts_with("https://") {
|
||||
@@ -505,6 +516,27 @@ async fn set_state(
|
||||
}
|
||||
}
|
||||
|
||||
/// The comment an open issue gets once when a complete scan no longer finds
|
||||
/// its CVE. It stays open: that the CVE is gone is no proof of a fix (#994).
|
||||
const GONE_COMMENT: &str = "**Prüfwerk:** Die Prüfung findet diese Schwachstelle nicht mehr. Das allein belegt keine Behebung: Bitte prüfen Sie, ob sie behoben ist, und schließen Sie das Issue dann selbst. In Prüfwerk können Sie dazu den VEX-Status \"Behoben\" mit Begründung setzen.\n\nThe scan no longer finds this vulnerability. That alone does not prove a fix: please check whether it is fixed and close the issue yourself. In Prüfwerk you can set the VEX status \"fixed\" with a reason.";
|
||||
|
||||
/// Store that `issue` was told its CVE is gone (`gone`), or that the CVE was
|
||||
/// found again.
|
||||
async fn note_gone(db: &Database, issue: &TrackerIssue, gone: bool) -> Result<(), AgentError> {
|
||||
let Some(id) = issue.id else {
|
||||
return Ok(());
|
||||
};
|
||||
let update = if gone {
|
||||
doc! { "$set": { "gone_noted_at": mongodb::bson::DateTime::now() } }
|
||||
} else {
|
||||
doc! { "$unset": { "gone_noted_at": "" } }
|
||||
};
|
||||
db.tracker_issues()
|
||||
.update_one(doc! { "_id": id }, update)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Store an issue's new state.
|
||||
async fn record(
|
||||
db: &Database,
|
||||
@@ -719,7 +751,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn severe_cves_open_issues_that_close_when_the_dependency_is_fixed() {
|
||||
async fn severe_cves_open_issues_a_person_closes_once_the_cve_is_gone() {
|
||||
let uri = std::env::var("TEST_MONGODB_URI")
|
||||
.unwrap_or_else(|_| "mongodb://root:example@localhost:27017/?authSource=admin".into());
|
||||
let prefix = format!(
|
||||
@@ -767,7 +799,8 @@ mod tests {
|
||||
// pruefwerk (1), cra:annex-i (2), severity:high (4), cve (7).
|
||||
assert!(calls[0].ends_with("labels=[1,2,4,7]"), "{}", calls[0]);
|
||||
assert!(calls[1].contains("Fixed in: 4.9.2"));
|
||||
assert!(calls[1].contains("cra-ai-22"));
|
||||
assert!(calls[1].contains("Bekannte Schwachstellen in Komponenten"));
|
||||
assert!(!calls[1].contains("cra-ai-22"));
|
||||
assert!(calls[1].contains("https://pruefwerk.example/targets/target-1"));
|
||||
}
|
||||
|
||||
@@ -783,30 +816,50 @@ mod tests {
|
||||
CveIssueCounts::default()
|
||||
);
|
||||
|
||||
// The dependency is updated: the complete scan finds it no more.
|
||||
// The complete scan finds it no more: the issue is told so once and
|
||||
// stays open, since a CVE that is gone is no proof of a fix (#994).
|
||||
let noted = CveIssueCounts {
|
||||
noted_gone: 1,
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(
|
||||
sync_cve_issues(&target, &[minor], true).await.unwrap(),
|
||||
CveIssueCounts {
|
||||
closed: 1,
|
||||
..Default::default()
|
||||
}
|
||||
sync_cve_issues(&target, std::slice::from_ref(&minor), true)
|
||||
.await
|
||||
.unwrap(),
|
||||
noted
|
||||
);
|
||||
{
|
||||
let calls = calls.lock().unwrap();
|
||||
let last = calls.last().unwrap();
|
||||
assert!(
|
||||
last.starts_with("comment 100: ") && last.contains("no longer finds"),
|
||||
"{last}"
|
||||
);
|
||||
assert!(calls.iter().all(|c| !c.starts_with("state ")), "{calls:?}");
|
||||
}
|
||||
let sent = calls.lock().unwrap().len();
|
||||
assert_eq!(
|
||||
calls.lock().unwrap().last().unwrap(),
|
||||
"state 100: \"closed\""
|
||||
sync_cve_issues(&target, std::slice::from_ref(&minor), true)
|
||||
.await
|
||||
.unwrap(),
|
||||
CveIssueCounts::default(),
|
||||
"told once"
|
||||
);
|
||||
assert_eq!(calls.lock().unwrap().len(), sent);
|
||||
|
||||
// It comes back: reopened, not opened twice.
|
||||
// It comes back: the issue is still open, so nothing is sent; gone
|
||||
// again, it is told again.
|
||||
assert_eq!(
|
||||
sync_cve_issues(&target, std::slice::from_ref(&okhttp), true)
|
||||
.await
|
||||
.unwrap(),
|
||||
CveIssueCounts {
|
||||
reopened: 1,
|
||||
..Default::default()
|
||||
}
|
||||
CveIssueCounts::default()
|
||||
);
|
||||
assert_eq!(calls.lock().unwrap().last().unwrap(), "state 100: \"open\"");
|
||||
assert_eq!(calls.lock().unwrap().len(), sent);
|
||||
assert_eq!(sync_cve_issues(&target, &[], true).await.unwrap(), noted);
|
||||
sync_cve_issues(&target, std::slice::from_ref(&okhttp), true)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// A person closes it in Gitea (#953): the scan that still finds the
|
||||
// CVE leaves it closed and sends nothing.
|
||||
@@ -997,6 +1050,55 @@ mod tests {
|
||||
pool.drop_tenant("cve-issues-vex").await.ok();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_cve_gone_from_the_scan_is_never_closed_as_vex_fixed() {
|
||||
let Some((pool, db)) = test_db("cve-issues-gone").await else {
|
||||
return;
|
||||
};
|
||||
let calls: Calls = Arc::default();
|
||||
let tracker = tracker_at(fake_gitea(calls.clone()).await);
|
||||
let target = vex_target(&db, &tracker, IssueAutoclose::On);
|
||||
// The `fixed` scans inferred from a CVE no longer found (#994).
|
||||
let mut log4j = alert("log4j-core", "2.14.1", "CVE-2021-44228", "CRITICAL");
|
||||
log4j.vex = Some(VexAssessment {
|
||||
by: "pruefwerk-scan".into(),
|
||||
by_scan: true,
|
||||
..vex(VexStatus::Fixed)
|
||||
});
|
||||
|
||||
// Reported with it: no statement, so the issue opens.
|
||||
let counts = sync_cve_issues(&target, std::slice::from_ref(&log4j), true)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
counts,
|
||||
CveIssueCounts {
|
||||
created: 1,
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
|
||||
// Gone: never closed, neither for being gone nor with a VEX status;
|
||||
// the issue is told once that the scan no longer finds the CVE.
|
||||
assert_eq!(
|
||||
sync_cve_issues(&target, &[], true).await.unwrap(),
|
||||
CveIssueCounts {
|
||||
noted_gone: 1,
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
{
|
||||
let calls = calls.lock().unwrap();
|
||||
assert!(calls.iter().all(|c| !c.starts_with("state ")), "{calls:?}");
|
||||
assert!(
|
||||
calls.iter().any(|c| c.contains("no longer finds")),
|
||||
"{calls:?}"
|
||||
);
|
||||
}
|
||||
|
||||
pool.drop_tenant("cve-issues-gone").await.ok();
|
||||
}
|
||||
|
||||
/// Log lines written while the returned guard lives (on this thread; a
|
||||
/// `#[tokio::test]` runs on one).
|
||||
fn capture_logs() -> (Arc<Mutex<Vec<u8>>>, tracing::subscriber::DefaultGuard) {
|
||||
|
||||
@@ -47,7 +47,6 @@ pub async fn notify_new_cves(
|
||||
);
|
||||
notification.cvss_score = alert.cvss_score;
|
||||
notification.summary = alert.summary.clone();
|
||||
notification.url = Some(format!("https://osv.dev/vulnerability/{}", alert.cve_id));
|
||||
let notification = match mongodb::bson::to_bson(¬ification) {
|
||||
Ok(n) => n,
|
||||
Err(e) => {
|
||||
|
||||
@@ -243,10 +243,11 @@ impl CveIssueSync<'_> {
|
||||
let counts =
|
||||
crate::pipeline::cve_issues::sync_cve_issues(&target, alerts, complete).await?;
|
||||
tracing::info!(
|
||||
"[{repo_id}] CVE issues: {} opened, {} reopened, {} closed",
|
||||
"[{repo_id}] CVE issues: {} opened, {} reopened, {} closed, {} told the CVE is gone",
|
||||
counts.created,
|
||||
counts.reopened,
|
||||
counts.closed
|
||||
counts.closed,
|
||||
counts.noted_gone
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
@@ -686,23 +687,18 @@ pub(super) fn format_issue_body(finding: &Finding) -> String {
|
||||
body
|
||||
}
|
||||
|
||||
/// The CRA requirements a finding is evidence for, as `cra-ai-8 — <title>`,
|
||||
/// from its stamped `control_refs`. Titles come from the CRA control map.
|
||||
fn cra_requirements(control_refs: &[String]) -> Vec<String> {
|
||||
let map = control_map::ControlMap::cra().ok();
|
||||
/// The CRA requirements a finding is evidence for, from its stamped
|
||||
/// `control_refs`, by the name a customer reads in both languages
|
||||
/// (`Keine Standardpasswörter / No default passwords (Annex I)`). An id
|
||||
/// outside the 40 requirements stays as it is.
|
||||
pub(crate) fn cra_requirements<S: AsRef<str>>(control_refs: &[S]) -> Vec<String> {
|
||||
control_refs
|
||||
.iter()
|
||||
.map(AsRef::as_ref)
|
||||
.filter(|id| id.starts_with("cra-"))
|
||||
.map(|id| {
|
||||
match map
|
||||
.as_ref()
|
||||
.and_then(|m| m.coverage(id))
|
||||
.map(|c| c.title.as_str())
|
||||
.filter(|t| !t.is_empty())
|
||||
{
|
||||
Some(title) => format!("{id} — {title} (Annex I)"),
|
||||
None => format!("{id} (Annex I)"),
|
||||
}
|
||||
.map(|id| match compliance_core::cra_requirements::name(id) {
|
||||
Some(name) => format!("{} / {} (Annex I)", name.de, name.en),
|
||||
None => format!("{id} (Annex I)"),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -736,9 +732,10 @@ mod tests {
|
||||
fn cra_requirements_name_the_control() {
|
||||
let refs = vec!["cra-ai-1".to_string(), "iec-x".to_string()];
|
||||
let lines = cra_requirements(&refs);
|
||||
assert_eq!(lines.len(), 1);
|
||||
assert!(lines[0].starts_with("cra-ai-1 — "), "{lines:?}");
|
||||
assert!(lines[0].ends_with("(Annex I)"));
|
||||
assert_eq!(
|
||||
lines,
|
||||
["Sichere Werkseinstellungen / Secure factory settings (Annex I)"]
|
||||
);
|
||||
assert_eq!(
|
||||
cra_requirements(&["cra-unknown".to_string()]),
|
||||
["cra-unknown (Annex I)"]
|
||||
@@ -760,7 +757,8 @@ mod tests {
|
||||
f.control_refs = vec!["cra-ai-1".into()];
|
||||
let body = format_issue_body(&f);
|
||||
assert!(body.contains("**CWE:** CWE-89"));
|
||||
assert!(body.contains("**CRA:** cra-ai-1"));
|
||||
assert!(body.contains("**CRA:** Sichere Werkseinstellungen / Secure factory settings"));
|
||||
assert!(!body.contains("cra-ai-1"));
|
||||
assert!(body.contains("`fp1`"));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
//!
|
||||
//! An alert is stored once per CVE and target. Reported again, it is updated
|
||||
//! and counts as open: a `fixed` the scan had stated is withdrawn. When a
|
||||
//! complete lookup no longer reports it (the component removed or updated
|
||||
//! past the fix), it is marked resolved, and one nobody assessed, or
|
||||
//! assessed as affected, gets the VEX status `fixed` from the scan. A
|
||||
//! person's `not_affected` or `fixed` is never changed by a scan. What a
|
||||
//! complete lookup no longer reports it, it is marked resolved, and its VEX
|
||||
//! status stays as it was: that a CVE is gone is no evidence of a fix, so a
|
||||
//! scan never states `fixed` for it (#994). A `fixed` scans stated that way
|
||||
//! before is read as no statement ([`CveAlert::statement`]) and withdrawn
|
||||
//! when the CVE is reported again. A person's statement is never changed by
|
||||
//! a scan. What a
|
||||
//! scan states from the target's own data (a Yocto recipe's CVE_STATUS or
|
||||
//! `CVE:` patch) is stated again on every scan, and likewise never replaces
|
||||
//! a person's statement. The first
|
||||
@@ -20,7 +22,7 @@
|
||||
use futures_util::TryStreamExt;
|
||||
use mongodb::bson::doc;
|
||||
|
||||
use compliance_core::models::{CveAlert, StatusChange, VexAssessment, VexStatus};
|
||||
use compliance_core::models::{CveAlert, VexAssessment};
|
||||
|
||||
use crate::database::{Database, DatabasePool};
|
||||
use crate::error::AgentError;
|
||||
@@ -308,6 +310,11 @@ pub async fn attach_stored_vex(
|
||||
/// Mark resolved the stored alerts of `repo_id` a complete lookup
|
||||
/// (`complete`) no longer reports in `current`.
|
||||
///
|
||||
/// That is what the scan observed, not a VEX statement: each alert keeps the
|
||||
/// statement it has, and one without stays without. A CVE can disappear for
|
||||
/// other reasons than a fix (other scan data, an incomplete inventory, a
|
||||
/// changed identification), so only a person states `fixed` (#994).
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// How many were resolved.
|
||||
@@ -324,52 +331,25 @@ pub async fn resolve_gone(
|
||||
if !complete {
|
||||
return Ok(0);
|
||||
}
|
||||
let now = mongodb::bson::DateTime::now();
|
||||
let seen: Vec<&str> = current.iter().map(|a| a.cve_id.as_str()).collect();
|
||||
let gone = doc! {
|
||||
"repo_id": repo_id,
|
||||
"cve_id": { "$nin": seen },
|
||||
"resolved_at": { "$exists": false },
|
||||
};
|
||||
let fixed = VexAssessment {
|
||||
status: VexStatus::Fixed,
|
||||
justification: None,
|
||||
impact_statement: None,
|
||||
action_statement: None,
|
||||
by: StatusChange::SCAN_ACTOR.to_string(),
|
||||
by_name: None,
|
||||
at: chrono::Utc::now(),
|
||||
by_scan: true,
|
||||
};
|
||||
let fixed = mongodb::bson::to_bson(&fixed)
|
||||
.map_err(|e| AgentError::Other(format!("encode VEX: {e}")))?;
|
||||
let mut unassessed = gone.clone();
|
||||
unassessed.insert(
|
||||
"$or",
|
||||
mongodb::bson::bson!([
|
||||
{ "vex": { "$exists": false } },
|
||||
{ "vex.status": { "$in": ["under_investigation", "affected"] } },
|
||||
]),
|
||||
);
|
||||
let became_fixed = db
|
||||
.cve_alerts()
|
||||
.update_many(
|
||||
unassessed,
|
||||
doc! { "$set": { "resolved_at": now, "vex": fixed } },
|
||||
)
|
||||
.await?;
|
||||
let resolved = db
|
||||
.cve_alerts()
|
||||
.update_many(gone, doc! { "$set": { "resolved_at": now } })
|
||||
.await?;
|
||||
let total = became_fixed.modified_count + resolved.modified_count;
|
||||
if total > 0 {
|
||||
.update_many(
|
||||
doc! {
|
||||
"repo_id": repo_id,
|
||||
"cve_id": { "$nin": seen },
|
||||
"resolved_at": { "$exists": false },
|
||||
},
|
||||
doc! { "$set": { "resolved_at": mongodb::bson::DateTime::now() } },
|
||||
)
|
||||
.await?
|
||||
.modified_count;
|
||||
if resolved > 0 {
|
||||
tracing::info!(
|
||||
repo_id,
|
||||
resolved = total,
|
||||
fixed_by_scan = became_fixed.modified_count,
|
||||
resolved,
|
||||
"CVE alerts no longer found marked resolved"
|
||||
);
|
||||
}
|
||||
Ok(total)
|
||||
Ok(resolved)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//! #498: a CVE alert's VEX status follows the scans. Gone after a complete
|
||||
//! lookup, an unassessed or affected alert is `fixed` by the scan, a
|
||||
//! person's `not_affected` stays; reported again, the scan's `fixed` is
|
||||
//! withdrawn. A stored alert gets its component's purl on a later scan. An
|
||||
//! lookup, an alert is resolved and keeps its statement or lack of one: a
|
||||
//! scan never states `fixed` for a CVE it no longer finds (#994). Reported
|
||||
//! again, a `fixed` scans inferred that way before is withdrawn. A stored alert gets its component's purl on a later scan. An
|
||||
//! alert `not_affected` or `fixed` raises no notification until the
|
||||
//! statement is withdrawn.
|
||||
//! Runs against a live Mongo (`TEST_MONGODB_URI`) and skips
|
||||
@@ -100,15 +100,12 @@ async fn vex_status_follows_the_scans_but_never_overrides_a_person() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Assert: three resolved; the unassessed and the affected one are fixed
|
||||
// by the scan, the person's not_affected stays.
|
||||
// Assert: three resolved, and no statement made: the unassessed one has
|
||||
// none, the person's not_affected and affected stay (#994).
|
||||
assert_eq!(resolved, 3);
|
||||
let one = stored(&db, "CVE-1").await;
|
||||
assert!(one.resolved_at.is_some());
|
||||
assert_eq!(
|
||||
one.vex.as_ref().map(|v| (v.status, v.by_scan)),
|
||||
Some((VexStatus::Fixed, true))
|
||||
);
|
||||
assert!(one.vex.is_none(), "{:?}", one.vex);
|
||||
let two = stored(&db, "CVE-2").await;
|
||||
assert!(two.resolved_at.is_some());
|
||||
assert_eq!(
|
||||
@@ -117,12 +114,27 @@ async fn vex_status_follows_the_scans_but_never_overrides_a_person() {
|
||||
);
|
||||
assert_eq!(
|
||||
stored(&db, "CVE-3").await.vex.map(|v| v.status),
|
||||
Some(VexStatus::Fixed)
|
||||
Some(VexStatus::Affected)
|
||||
);
|
||||
assert!(stored(&db, "CVE-4").await.resolved_at.is_none());
|
||||
|
||||
// Reported again: open, and the scan's `fixed` is withdrawn; the
|
||||
// person's statement is kept.
|
||||
// Reported again: open, and the `fixed` a scan inferred before #994 is
|
||||
// withdrawn; the person's statement is kept.
|
||||
let inferred = VexAssessment {
|
||||
justification: None,
|
||||
action_statement: None,
|
||||
by: "pruefwerk-scan".into(),
|
||||
by_name: None,
|
||||
by_scan: true,
|
||||
..by_person(VexStatus::Fixed)
|
||||
};
|
||||
db.cve_alerts()
|
||||
.update_one(
|
||||
doc! { "cve_id": "CVE-1" },
|
||||
doc! { "$set": { "vex": mongodb::bson::to_bson(&inferred).unwrap() } },
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
upsert_reported(&db, &alert("CVE-1")).await.unwrap();
|
||||
upsert_reported(&db, &alert("CVE-2")).await.unwrap();
|
||||
let one = stored(&db, "CVE-1").await;
|
||||
|
||||
@@ -0,0 +1,683 @@
|
||||
//! The 40 CRA Annex I requirements in the words a customer reads: a name
|
||||
//! that says what the requirement is about, and for each state what it means
|
||||
//! for that requirement (#sps2026 item 10).
|
||||
//!
|
||||
//! The catalog (`cra-ai-1` … `cra-ai-40`) stays the source of the ids and of
|
||||
//! the legal wording; people never see those ids. Machine-readable exports
|
||||
//! (CSAF, VEX, OSCAL, JSON) keep them.
|
||||
|
||||
/// One text in both languages of the product.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Words {
|
||||
/// German.
|
||||
pub de: &'static str,
|
||||
/// English.
|
||||
pub en: &'static str,
|
||||
}
|
||||
|
||||
/// The area a requirement belongs to, in the catalog's group order.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub enum CraArea {
|
||||
/// Secure by design (`cra-ai-1` … `6`).
|
||||
SecureDesign,
|
||||
/// Sign-in and access (`7` … `12`).
|
||||
Access,
|
||||
/// Encryption (`13` … `17`).
|
||||
Encryption,
|
||||
/// Development (`18` … `20`).
|
||||
Development,
|
||||
/// Supply chain (`21` … `23`).
|
||||
SupplyChain,
|
||||
/// Logs (`24` … `27`).
|
||||
Logging,
|
||||
/// Updates (`28` … `31`).
|
||||
Updates,
|
||||
/// Vulnerabilities and incidents (`32` … `40`).
|
||||
Vulnerabilities,
|
||||
}
|
||||
|
||||
impl CraArea {
|
||||
/// Every area, in the order the views show them.
|
||||
pub const ALL: [Self; 8] = [
|
||||
Self::SecureDesign,
|
||||
Self::Access,
|
||||
Self::Encryption,
|
||||
Self::Development,
|
||||
Self::SupplyChain,
|
||||
Self::Logging,
|
||||
Self::Updates,
|
||||
Self::Vulnerabilities,
|
||||
];
|
||||
|
||||
/// The area's name.
|
||||
pub const fn name(self) -> Words {
|
||||
match self {
|
||||
Self::SecureDesign => w("Sicher entworfen", "Secure by design"),
|
||||
Self::Access => w("Anmeldung und Zugriff", "Sign-in and access"),
|
||||
Self::Encryption => w("Verschlüsselung", "Encryption"),
|
||||
Self::Development => w("Entwicklung", "Development"),
|
||||
Self::SupplyChain => w("Lieferkette", "Supply chain"),
|
||||
Self::Logging => w("Protokolle", "Logs"),
|
||||
Self::Updates => w("Updates", "Updates"),
|
||||
Self::Vulnerabilities => w(
|
||||
"Schwachstellen und Vorfälle",
|
||||
"Vulnerabilities and incidents",
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One requirement as a customer reads it.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct CraRequirement {
|
||||
/// The catalog id (`cra-ai-8`).
|
||||
pub id: &'static str,
|
||||
/// Its area.
|
||||
pub area: CraArea,
|
||||
/// Its name (`Keine Standardpasswörter`).
|
||||
pub name: Words,
|
||||
/// What red means here: what an open finding against it shows. `None`
|
||||
/// for a requirement a code scan cannot decide.
|
||||
pub against: Option<Words>,
|
||||
/// What green means here: what the scan did not find.
|
||||
pub clear: Option<Words>,
|
||||
/// The document that proves a requirement no code scan decides, as the
|
||||
/// end of "Sie weisen sie nach mit …" (`ein Rechtekonzept`).
|
||||
pub proof: Option<Words>,
|
||||
}
|
||||
|
||||
/// What orange means for every requirement: only part of what it covers was
|
||||
/// checked.
|
||||
pub const PARTLY_CHECKED: Words = w(
|
||||
"Nur ein Teil wurde geprüft, zum Beispiel bei einem Yocto-Image die Rezeptliste statt des \
|
||||
fertigen Images.",
|
||||
"Only part was checked, for example a Yocto image's recipe list instead of the built image.",
|
||||
);
|
||||
|
||||
/// The requirement with catalog id `id`, if it is one of the 40.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use compliance_core::cra_requirements::requirement;
|
||||
/// assert_eq!(requirement("cra-ai-8").unwrap().name.de, "Keine Standardpasswörter");
|
||||
/// assert!(requirement("cra-ai-20-csharp-xxe").is_none());
|
||||
/// ```
|
||||
pub fn requirement(id: &str) -> Option<&'static CraRequirement> {
|
||||
let number: usize = id.strip_prefix("cra-ai-")?.parse().ok()?;
|
||||
CRA_REQUIREMENTS
|
||||
.get(number.checked_sub(1)?)
|
||||
.filter(|r| r.id == id)
|
||||
}
|
||||
|
||||
/// The name of requirement `id` in German and English, or `None` for an id
|
||||
/// that is not one of the 40.
|
||||
pub fn name(id: &str) -> Option<Words> {
|
||||
requirement(id).map(|r| r.name)
|
||||
}
|
||||
|
||||
const fn w(de: &'static str, en: &'static str) -> Words {
|
||||
Words { de, en }
|
||||
}
|
||||
|
||||
/// A requirement a code scan checks.
|
||||
const fn checked(
|
||||
id: &'static str,
|
||||
area: CraArea,
|
||||
name: Words,
|
||||
against: Words,
|
||||
clear: Words,
|
||||
) -> CraRequirement {
|
||||
CraRequirement {
|
||||
id,
|
||||
area,
|
||||
name,
|
||||
against: Some(against),
|
||||
clear: Some(clear),
|
||||
proof: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// A requirement proven by a document.
|
||||
const fn proven(id: &'static str, area: CraArea, name: Words, proof: Words) -> CraRequirement {
|
||||
CraRequirement {
|
||||
id,
|
||||
area,
|
||||
name,
|
||||
against: None,
|
||||
clear: None,
|
||||
proof: Some(proof),
|
||||
}
|
||||
}
|
||||
|
||||
use CraArea::{
|
||||
Access, Development, Encryption, Logging, SecureDesign, SupplyChain, Updates, Vulnerabilities,
|
||||
};
|
||||
|
||||
/// The 40 requirements, `cra-ai-1` first.
|
||||
pub const CRA_REQUIREMENTS: [CraRequirement; 40] = [
|
||||
checked(
|
||||
"cra-ai-1",
|
||||
SecureDesign,
|
||||
w("Sichere Werkseinstellungen", "Secure factory settings"),
|
||||
w(
|
||||
"Im Auslieferungszustand ist etwas offen, das es nicht sein muss, etwa eine \
|
||||
Debug-Schnittstelle oder ein unnötiger Dienst.",
|
||||
"Something is open as shipped that need not be, such as a debug interface or an \
|
||||
unneeded service.",
|
||||
),
|
||||
w(
|
||||
"Der Scan fand keine unsicheren Voreinstellungen.",
|
||||
"The scan found no insecure defaults.",
|
||||
),
|
||||
),
|
||||
// Decided in code only on a Yocto layer tree, so it has both.
|
||||
CraRequirement {
|
||||
id: "cra-ai-2",
|
||||
area: SecureDesign,
|
||||
name: w("Nur nötige Dienste aktiv", "Only needed services running"),
|
||||
against: Some(w(
|
||||
"Das Image startet Dienste oder öffnet Schnittstellen, die das Gerät nicht braucht.",
|
||||
"The image starts services or opens interfaces the device does not need.",
|
||||
)),
|
||||
clear: Some(w(
|
||||
"Im Image fand der Scan keine unnötig aktiven Dienste.",
|
||||
"The scan found no needlessly running services in the image.",
|
||||
)),
|
||||
proof: Some(w(
|
||||
"eine Liste der Dienste und Schnittstellen mit ihrem Zweck",
|
||||
"a list of services and interfaces with their purpose",
|
||||
)),
|
||||
},
|
||||
proven(
|
||||
"cra-ai-3",
|
||||
SecureDesign,
|
||||
w("Getrennte Sicherheitsbereiche", "Separated security zones"),
|
||||
w(
|
||||
"eine Architekturbeschreibung",
|
||||
"an architecture description",
|
||||
),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-4",
|
||||
SecureDesign,
|
||||
w("Nur die nötigen Rechte", "Only the rights needed"),
|
||||
w("ein Rechtekonzept", "a permissions concept"),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-5",
|
||||
SecureDesign,
|
||||
w("Schutz vor Manipulation", "Protection against tampering"),
|
||||
w(
|
||||
"eine Beschreibung von Secure Boot und Code-Signatur",
|
||||
"a description of secure boot and code signing",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-6",
|
||||
SecureDesign,
|
||||
w("Prüfung auf Veränderung", "Checks for modification"),
|
||||
w(
|
||||
"Software oder Firmware wird geladen, ohne vorher zu prüfen, ob sie verändert wurde.",
|
||||
"Software or firmware is loaded without first checking whether it was modified.",
|
||||
),
|
||||
w(
|
||||
"An den Stellen, an denen Software geladen wird, fand der Scan eine Prüfung auf \
|
||||
Veränderung.",
|
||||
"Where software is loaded, the scan found a check for modification.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-7",
|
||||
Access,
|
||||
w("Sichere Anmeldung", "Secure sign-in"),
|
||||
w(
|
||||
"Eine Anmeldung ist schwach umgesetzt, etwa ohne Passwortprüfung oder mit einem \
|
||||
veralteten Verfahren.",
|
||||
"A sign-in is weakly built, for example without a password check or with an \
|
||||
outdated method.",
|
||||
),
|
||||
w(
|
||||
"Der Scan fand keine schwach umgesetzte Anmeldung.",
|
||||
"The scan found no weakly built sign-in.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-8",
|
||||
Access,
|
||||
w("Keine Standardpasswörter", "No default passwords"),
|
||||
w(
|
||||
"Im Code oder im Image steckt ein fest eingebautes Passwort, das auf jedem Gerät \
|
||||
gleich ist.",
|
||||
"The code or image holds a built-in password that is the same on every device.",
|
||||
),
|
||||
w(
|
||||
"Der Scan fand kein fest eingebautes Passwort.",
|
||||
"The scan found no built-in password.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-9",
|
||||
Access,
|
||||
w("Zugangsdaten sicher verwahrt", "Credentials kept safe"),
|
||||
w(
|
||||
"Zugangsdaten, Tokens oder Schlüssel liegen im Klartext im Code oder in Dateien.",
|
||||
"Credentials, tokens or keys are in plain text in the code or in files.",
|
||||
),
|
||||
w(
|
||||
"Der Scan fand keine Zugangsdaten im Klartext.",
|
||||
"The scan found no credentials in plain text.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-10",
|
||||
Access,
|
||||
w("Sitzungen enden sicher", "Sessions end safely"),
|
||||
w(
|
||||
"Sitzungen laufen nicht ab oder sind nicht gegen untergeschobene Anfragen geschützt.",
|
||||
"Sessions do not expire or are not protected against forged requests.",
|
||||
),
|
||||
w(
|
||||
"Der Scan fand keine unsicher verwalteten Sitzungen.",
|
||||
"The scan found no unsafely managed sessions.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-11",
|
||||
Access,
|
||||
w(
|
||||
"Schutz vor Passwort-Raten",
|
||||
"Protection against password guessing",
|
||||
),
|
||||
w(
|
||||
"Eine Anmeldung erlaubt beliebig viele Versuche.",
|
||||
"A sign-in allows any number of attempts.",
|
||||
),
|
||||
w(
|
||||
"Wo man sich anmeldet, ist die Zahl der Versuche begrenzt.",
|
||||
"Where people sign in, the number of attempts is limited.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-12",
|
||||
Access,
|
||||
w("Rollen und Rechte", "Roles and permissions"),
|
||||
w(
|
||||
"Funktionen für Administratoren sind ohne Rechteprüfung erreichbar.",
|
||||
"Administrator functions can be reached without a permission check.",
|
||||
),
|
||||
w(
|
||||
"Vor den geschützten Funktionen fand der Scan eine Rechteprüfung.",
|
||||
"The scan found a permission check before the protected functions.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-13",
|
||||
Encryption,
|
||||
w(
|
||||
"Vertrauliche Daten verschlüsselt",
|
||||
"Sensitive data encrypted",
|
||||
),
|
||||
w(
|
||||
"Vertrauliche Daten werden unverschlüsselt oder mit einem veralteten Verfahren \
|
||||
verarbeitet.",
|
||||
"Sensitive data is handled unencrypted or with an outdated method.",
|
||||
),
|
||||
w(
|
||||
"Der Scan fand keine unverschlüsselten vertraulichen Daten.",
|
||||
"The scan found no unencrypted sensitive data.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-14",
|
||||
Encryption,
|
||||
w("Gespeicherte Daten verschlüsselt", "Stored data encrypted"),
|
||||
w(
|
||||
"Daten werden unverschlüsselt oder mit einem schwachen Verfahren gespeichert.",
|
||||
"Data is stored unencrypted or with a weak method.",
|
||||
),
|
||||
w(
|
||||
"Der Scan fand keine unverschlüsselt gespeicherten Daten.",
|
||||
"The scan found no data stored unencrypted.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-15",
|
||||
Encryption,
|
||||
w("Verbindungen verschlüsselt", "Connections encrypted"),
|
||||
w(
|
||||
"Eine Verbindung läuft unverschlüsselt oder mit altem SSL/TLS.",
|
||||
"A connection runs unencrypted or over old SSL/TLS.",
|
||||
),
|
||||
w(
|
||||
"Alle gefundenen Verbindungen nutzen aktuelle Verschlüsselung.",
|
||||
"Every connection found uses current encryption.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-16",
|
||||
Encryption,
|
||||
w("Schlüssel sicher verwahrt", "Keys kept safe"),
|
||||
w(
|
||||
"Ein kryptografischer Schlüssel steht im Code oder liegt ungeschützt bei den Dateien.",
|
||||
"A cryptographic key is written in the code or lies unprotected among the files.",
|
||||
),
|
||||
w(
|
||||
"Der Scan fand keinen ungeschützten Schlüssel.",
|
||||
"The scan found no unprotected key.",
|
||||
),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-17",
|
||||
Encryption,
|
||||
w("Nur nötige Daten erfassen", "Collect only the data needed"),
|
||||
w("ein Datenschutzkonzept", "a data protection concept"),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-18",
|
||||
Development,
|
||||
w(
|
||||
"Sicherheit im Entwicklungsablauf",
|
||||
"Security in the development process",
|
||||
),
|
||||
w(
|
||||
"eine Beschreibung Ihres Entwicklungsablaufs",
|
||||
"a description of your development process",
|
||||
),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-19",
|
||||
Development,
|
||||
w("Code-Prüfung durch Kollegen", "Code review by colleagues"),
|
||||
w("Ihre Regeln für Code-Reviews", "your code review rules"),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-20",
|
||||
Development,
|
||||
w("Sicherer Programmcode", "Safe program code"),
|
||||
w(
|
||||
"Im Code stecken unsichere Muster, etwa ungeprüfte Eingaben oder unsichere \
|
||||
C-Funktionen.",
|
||||
"The code holds unsafe patterns, such as unchecked input or unsafe C functions.",
|
||||
),
|
||||
w(
|
||||
"Die Sicherheitstests fanden keine unsicheren Muster.",
|
||||
"The security tests found no unsafe patterns.",
|
||||
),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-21",
|
||||
SupplyChain,
|
||||
w("Fremdkomponenten geprüft", "Third-party components vetted"),
|
||||
w(
|
||||
"Ihren Prüfablauf für zugekaufte Komponenten",
|
||||
"your vetting process for bought-in components",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-22",
|
||||
SupplyChain,
|
||||
w(
|
||||
"Bekannte Schwachstellen in Komponenten",
|
||||
"Known vulnerabilities in components",
|
||||
),
|
||||
w(
|
||||
"Eine eingesetzte Komponente hat eine bekannte Schwachstelle, die noch offen ist.",
|
||||
"A component in use has a known vulnerability that is still open.",
|
||||
),
|
||||
w(
|
||||
"Für keine eingesetzte Komponente ist eine offene Schwachstelle bekannt.",
|
||||
"No component in use has a known open vulnerability.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-23",
|
||||
SupplyChain,
|
||||
w(
|
||||
"Vollständige Stückliste (SBOM)",
|
||||
"Complete bill of materials (SBOM)",
|
||||
),
|
||||
w(
|
||||
"Die Stückliste fehlt, oder ihr fehlen Angaben wie Version oder Lizenz.",
|
||||
"The bill of materials is missing, or lacks details such as version or licence.",
|
||||
),
|
||||
w(
|
||||
"Die Stückliste ist vollständig und maschinenlesbar.",
|
||||
"The bill of materials is complete and machine-readable.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-24",
|
||||
Logging,
|
||||
w(
|
||||
"Sicherheitsereignisse protokolliert",
|
||||
"Security events logged",
|
||||
),
|
||||
w(
|
||||
"Anmeldungen, Rechteänderungen oder Aktionen von Administratoren werden nicht \
|
||||
protokolliert.",
|
||||
"Sign-ins, permission changes or administrator actions are not logged.",
|
||||
),
|
||||
w(
|
||||
"Der Scan fand eine Protokollierung der sicherheitsrelevanten Ereignisse.",
|
||||
"The scan found the security-relevant events being logged.",
|
||||
),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-25",
|
||||
Logging,
|
||||
w("Zentrale Überwachung", "Central monitoring"),
|
||||
w("Ihr Überwachungskonzept", "your monitoring concept"),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-26",
|
||||
Logging,
|
||||
w(
|
||||
"Angriffe automatisch erkannt",
|
||||
"Attacks detected automatically",
|
||||
),
|
||||
w(
|
||||
"eine Beschreibung Ihrer Angriffserkennung",
|
||||
"a description of your attack detection",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-27",
|
||||
Logging,
|
||||
w("Fälschungssichere Protokolle", "Tamper-proof logs"),
|
||||
w(
|
||||
"Protokolle lassen sich nachträglich ändern oder werden zu kurz aufbewahrt.",
|
||||
"Logs can be changed afterwards or are kept too briefly.",
|
||||
),
|
||||
w(
|
||||
"Der Scan fand keine änderbaren oder zu kurz aufbewahrten Protokolle.",
|
||||
"The scan found no logs that can be changed or are kept too briefly.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-28",
|
||||
Updates,
|
||||
w("Sicherer Update-Weg", "Secure update channel"),
|
||||
w(
|
||||
"Updates kommen über einen ungesicherten Weg, etwa per HTTP.",
|
||||
"Updates arrive over an unsecured channel, such as plain HTTP.",
|
||||
),
|
||||
w(
|
||||
"Updates kommen über einen gesicherten Weg.",
|
||||
"Updates arrive over a secured channel.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-29",
|
||||
Updates,
|
||||
w("Signierte Updates", "Signed updates"),
|
||||
w(
|
||||
"Ein Update wird installiert, ohne vorher seine Signatur zu prüfen.",
|
||||
"An update is installed without first checking its signature.",
|
||||
),
|
||||
w(
|
||||
"Vor der Installation wird die Signatur eines Updates geprüft.",
|
||||
"An update's signature is checked before it is installed.",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-30",
|
||||
Updates,
|
||||
w("Unversehrte Update-Pakete", "Intact update packages"),
|
||||
w(
|
||||
"Update-Pakete werden ohne Prüfsumme oder Signatur übernommen.",
|
||||
"Update packages are taken without a checksum or signature.",
|
||||
),
|
||||
w(
|
||||
"Update-Pakete werden vor der Übernahme geprüft.",
|
||||
"Update packages are checked before they are taken.",
|
||||
),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-31",
|
||||
Updates,
|
||||
w(
|
||||
"Updates über die Lebensdauer",
|
||||
"Updates over the product's lifetime",
|
||||
),
|
||||
w(
|
||||
"eine Support-Zusage mit Enddatum",
|
||||
"a support commitment with an end date",
|
||||
),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-32",
|
||||
Vulnerabilities,
|
||||
w(
|
||||
"Schwachstellen werden gesucht",
|
||||
"Vulnerabilities are looked for",
|
||||
),
|
||||
w(
|
||||
"Ihren Meldeweg und Ihre Überwachung",
|
||||
"your reporting channel and monitoring",
|
||||
),
|
||||
),
|
||||
checked(
|
||||
"cra-ai-33",
|
||||
Vulnerabilities,
|
||||
w(
|
||||
"Stückliste laufend geprüft",
|
||||
"Bill of materials checked continuously",
|
||||
),
|
||||
w(
|
||||
"Die Stückliste nennt Komponenten mit neu bekannt gewordenen Schwachstellen.",
|
||||
"The bill of materials lists components with newly known vulnerabilities.",
|
||||
),
|
||||
w(
|
||||
"Bei jedem Scan wird die Stückliste gegen bekannte Schwachstellen geprüft; nichts \
|
||||
ist offen.",
|
||||
"Every scan checks the bill of materials against known vulnerabilities; nothing is \
|
||||
open.",
|
||||
),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-34",
|
||||
Vulnerabilities,
|
||||
w("Wichtiges zuerst beheben", "Fix what matters first"),
|
||||
w("Ihre Fristen für die Behebung", "your deadlines for fixes"),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-35",
|
||||
Vulnerabilities,
|
||||
w(
|
||||
"Meldestelle für Schwachstellen",
|
||||
"Vulnerability reporting contact",
|
||||
),
|
||||
w(
|
||||
"eine veröffentlichte Kontaktadresse für Meldungen",
|
||||
"a published contact address for reports",
|
||||
),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-36",
|
||||
Vulnerabilities,
|
||||
w("Plan für Sicherheitsvorfälle", "Incident response plan"),
|
||||
w("Ihren Notfallplan", "your emergency plan"),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-37",
|
||||
Vulnerabilities,
|
||||
w(
|
||||
"Frühwarnung binnen 24 Stunden",
|
||||
"Early warning within 24 hours",
|
||||
),
|
||||
w(
|
||||
"Ihren Meldeablauf an ENISA und CSIRT",
|
||||
"your reporting procedure to ENISA and the CSIRT",
|
||||
),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-38",
|
||||
Vulnerabilities,
|
||||
w(
|
||||
"Vorfallsbericht binnen 72 Stunden",
|
||||
"Incident report within 72 hours",
|
||||
),
|
||||
w("Ihre Berichtsvorlage", "your report template"),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-39",
|
||||
Vulnerabilities,
|
||||
w("Sicherheits-Updates bereitstellen", "Ship security updates"),
|
||||
w(
|
||||
"Ihren Ablauf für Sicherheits-Updates",
|
||||
"your procedure for security updates",
|
||||
),
|
||||
),
|
||||
proven(
|
||||
"cra-ai-40",
|
||||
Vulnerabilities,
|
||||
w("Lückenlos dokumentiert", "Fully documented"),
|
||||
w(
|
||||
"Ihre Dokumentation, zehn Jahre aufbewahrt",
|
||||
"your documentation, kept for ten years",
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_table_is_in_id_order_and_every_id_resolves() {
|
||||
for (i, r) in CRA_REQUIREMENTS.iter().enumerate() {
|
||||
assert_eq!(r.id, format!("cra-ai-{}", i + 1));
|
||||
assert_eq!(requirement(r.id), Some(r));
|
||||
}
|
||||
assert!(requirement("cra-ai-0").is_none());
|
||||
assert!(requirement("cra-ai-41").is_none());
|
||||
assert!(requirement("cra-ai-8-csharp-hardcoded-credential").is_none());
|
||||
assert!(requirement("mc-1").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_requirement_says_what_its_states_mean() {
|
||||
for r in &CRA_REQUIREMENTS {
|
||||
assert_eq!(r.against.is_some(), r.clear.is_some(), "{}", r.id);
|
||||
assert!(r.against.is_some() || r.proof.is_some(), "{}", r.id);
|
||||
for words in [Some(r.name), r.against, r.clear, r.proof]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
{
|
||||
assert!(!words.de.is_empty() && !words.en.is_empty(), "{}", r.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn names_are_unique_and_every_area_has_requirements() {
|
||||
let mut names: Vec<&str> = CRA_REQUIREMENTS.iter().map(|r| r.name.de).collect();
|
||||
names.sort_unstable();
|
||||
names.dedup();
|
||||
assert_eq!(names.len(), CRA_REQUIREMENTS.len());
|
||||
for area in CraArea::ALL {
|
||||
assert!(CRA_REQUIREMENTS.iter().any(|r| r.area == area), "{area:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,9 @@ fn vulnerability(
|
||||
let product = in_product(id);
|
||||
let status = status_of(alert);
|
||||
push_product(&mut v, "product_status", status_key(status), &product);
|
||||
let Some(vex) = &alert.vex else { continue };
|
||||
let Some(vex) = alert.statement() else {
|
||||
continue;
|
||||
};
|
||||
match status {
|
||||
VexStatus::NotAffected => {
|
||||
if let Some(justification) = vex.justification {
|
||||
|
||||
@@ -141,9 +141,10 @@ impl PackageKey {
|
||||
}
|
||||
|
||||
/// Whether `alert` still asks for a decision: neither stated `not_affected`
|
||||
/// or `fixed`, nor found gone by a complete scan.
|
||||
/// or `fixed`, nor found gone by a complete scan. Gone is not `fixed`
|
||||
/// (#994); it only takes the alert off the list.
|
||||
pub fn is_open(alert: &CveAlert) -> bool {
|
||||
!status_of(alert).resolves()
|
||||
alert.resolved_at.is_none() && !status_of(alert).resolves()
|
||||
}
|
||||
|
||||
/// The open CVE alerts of one component.
|
||||
|
||||
@@ -142,9 +142,12 @@ pub enum Reportability {
|
||||
NotExploited,
|
||||
/// The manufacturer stated the product is not affected.
|
||||
NotAffected,
|
||||
/// The product no longer contains the vulnerable component or version,
|
||||
/// and no scan found it exploited while it did.
|
||||
/// Stated `fixed` (VEX), and no scan found it exploited before.
|
||||
Fixed,
|
||||
/// A complete scan no longer finds it and no scan found it exploited
|
||||
/// before, but nobody stated it `fixed`: that it is gone is no evidence
|
||||
/// of a fix (#994).
|
||||
NoLongerFound,
|
||||
}
|
||||
|
||||
impl Reportability {
|
||||
@@ -156,9 +159,10 @@ impl Reportability {
|
||||
}
|
||||
Self::NotExploited => "not known to be actively exploited",
|
||||
Self::NotAffected => "the product is not affected (VEX not_affected)",
|
||||
Self::Fixed => {
|
||||
"the product no longer contains the vulnerable component (VEX fixed), and no \
|
||||
scan found it exploited before"
|
||||
Self::Fixed => "stated fixed (VEX fixed), and no scan found it exploited before",
|
||||
Self::NoLongerFound => {
|
||||
"a complete scan no longer finds it and no scan found it exploited before; \
|
||||
nobody has stated it fixed, so this says nothing about a fix"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,10 +178,16 @@ pub fn reportability(alert: &CveAlert) -> Reportability {
|
||||
.exploitation
|
||||
.as_ref()
|
||||
.is_some_and(|e| e.actively_exploited());
|
||||
let seen_exploited = alert.exploited_seen_at.is_some();
|
||||
match (exploited, status_of(alert)) {
|
||||
(false, _) => Reportability::NotExploited,
|
||||
(true, VexStatus::NotAffected) => Reportability::NotAffected,
|
||||
(true, VexStatus::Fixed) if alert.exploited_seen_at.is_none() => Reportability::Fixed,
|
||||
(true, VexStatus::Fixed) if !seen_exploited => Reportability::Fixed,
|
||||
(true, VexStatus::Affected | VexStatus::UnderInvestigation)
|
||||
if !seen_exploited && alert.resolved_at.is_some() =>
|
||||
{
|
||||
Reportability::NoLongerFound
|
||||
}
|
||||
(true, VexStatus::Affected | VexStatus::UnderInvestigation | VexStatus::Fixed) => {
|
||||
Reportability::Reportable
|
||||
}
|
||||
@@ -185,17 +195,13 @@ pub fn reportability(alert: &CveAlert) -> Reportability {
|
||||
}
|
||||
|
||||
/// When the fix became available, as far as Prüfwerk knows: when a person
|
||||
/// stated `fixed`, else when a scan found the component gone.
|
||||
/// stated `fixed`. A scan finding the component gone dates no fix (#994),
|
||||
/// so without the statement the final report has no deadline yet.
|
||||
fn fixed_at(alert: &CveAlert) -> Option<DateTime<Utc>> {
|
||||
if status_of(alert) != VexStatus::Fixed {
|
||||
return None;
|
||||
}
|
||||
alert
|
||||
.vex
|
||||
.as_ref()
|
||||
.statement()
|
||||
.filter(|v| v.status == VexStatus::Fixed && !v.by_scan)
|
||||
.map(|v| v.at)
|
||||
.or(alert.resolved_at)
|
||||
}
|
||||
|
||||
/// The alerts of one vulnerability, grouped by CVE ([`CveAlert::cve`]): a
|
||||
@@ -297,8 +303,7 @@ pub struct EnisaInput<'a> {
|
||||
/// the fixed version.
|
||||
fn user_measures(alert: &CveAlert) -> Option<String> {
|
||||
alert
|
||||
.vex
|
||||
.as_ref()
|
||||
.statement()
|
||||
.and_then(|v| v.action_statement.clone())
|
||||
.or_else(|| {
|
||||
(!alert.fixed_versions.is_empty()).then(|| {
|
||||
@@ -389,7 +394,7 @@ fn value(nr: &str, input: &EnisaInput<'_>) -> Option<serde_json::Value> {
|
||||
"12" => text(components(alerts)),
|
||||
"14" | "17" => joined(alerts, user_measures).and_then(text),
|
||||
"16" => joined(alerts, |a| {
|
||||
a.vex.as_ref().and_then(|v| v.action_statement.clone())
|
||||
a.statement().and_then(|v| v.action_statement.clone())
|
||||
})
|
||||
.and_then(text),
|
||||
"v19" => cve.starts_with("CVE-").then(|| serde_json::json!(cve)),
|
||||
@@ -422,8 +427,7 @@ fn value(nr: &str, input: &EnisaInput<'_>) -> Option<serde_json::Value> {
|
||||
})
|
||||
}
|
||||
"v25" => joined(alerts, |a| {
|
||||
a.vex
|
||||
.as_ref()
|
||||
a.statement()
|
||||
.and_then(|v| v.impact_statement.clone())
|
||||
.or_else(|| a.llm_impact_summary.clone())
|
||||
})
|
||||
@@ -553,20 +557,66 @@ mod tests {
|
||||
assert_eq!(reportability(&a), Reportability::NotAffected);
|
||||
a.vex = None;
|
||||
a.resolved_at = Some(Utc::now());
|
||||
// Gone from the scan is no fix (#994), and no reason to report.
|
||||
assert_eq!(reportability(&a), Reportability::NoLongerFound);
|
||||
a.vex = Some(statement(VexStatus::Fixed));
|
||||
assert_eq!(reportability(&a), Reportability::Fixed);
|
||||
// Found exploited while the product contained it: the final report
|
||||
// is still due.
|
||||
a.exploited_seen_at = Some(at("2026-10-06T08:00:00Z"));
|
||||
assert_eq!(reportability(&a), Reportability::Reportable);
|
||||
a.vex = None;
|
||||
assert_eq!(reportability(&a), Reportability::Reportable);
|
||||
a.exploitation = None;
|
||||
assert_eq!(reportability(&a), Reportability::NotExploited);
|
||||
}
|
||||
|
||||
/// The final report's draft of `a`, aware at the first exploitation.
|
||||
fn final_report_draft(a: &CveAlert) -> serde_json::Value {
|
||||
draft(&EnisaInput {
|
||||
product: "Pump Remote",
|
||||
manufacturer: "example-pumps",
|
||||
tooling: "Prüfwerk test",
|
||||
alerts: &[a],
|
||||
aware_at: at("2026-10-01T08:00:00Z"),
|
||||
now: at("2026-10-06T09:00:00Z"),
|
||||
})
|
||||
}
|
||||
|
||||
/// The final report's due date while no fix is dated.
|
||||
const UNDATED_FINAL_REPORT: &str = "14 days after the date in field v22";
|
||||
|
||||
#[test]
|
||||
fn a_vulnerability_a_scan_no_longer_finds_dates_no_final_report() {
|
||||
let mut a = alert();
|
||||
a.exploited_seen_at = Some(at("2026-10-01T08:00:00Z"));
|
||||
a.resolved_at = Some(at("2026-10-05T10:00:00Z"));
|
||||
let doc = final_report_draft(&a);
|
||||
assert_eq!(doc["due"]["final_report"], UNDATED_FINAL_REPORT);
|
||||
|
||||
// Nor does a `fixed` a scan inferred from that before #994.
|
||||
a.vex = Some(VexAssessment {
|
||||
impact_statement: None,
|
||||
by: "pruefwerk-scan".into(),
|
||||
by_scan: true,
|
||||
at: at("2026-10-05T10:00:00Z"),
|
||||
..statement(VexStatus::Fixed)
|
||||
});
|
||||
assert_eq!(fixed_at(&a), None);
|
||||
assert_eq!(status_of(&a), VexStatus::UnderInvestigation);
|
||||
let doc = final_report_draft(&a);
|
||||
assert_eq!(doc["due"]["final_report"], UNDATED_FINAL_REPORT);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_fixed_vulnerability_dates_its_final_report() {
|
||||
let mut a = alert();
|
||||
a.exploited_seen_at = Some(at("2026-10-01T08:00:00Z"));
|
||||
a.resolved_at = Some(at("2026-10-05T10:00:00Z"));
|
||||
a.resolved_at = Some(at("2026-10-04T10:00:00Z"));
|
||||
a.vex = Some(VexAssessment {
|
||||
at: at("2026-10-05T10:00:00Z"),
|
||||
..statement(VexStatus::Fixed)
|
||||
});
|
||||
let doc = draft(&EnisaInput {
|
||||
product: "Pump Remote",
|
||||
manufacturer: "example-pumps",
|
||||
|
||||
@@ -2,6 +2,7 @@ pub mod build_info;
|
||||
pub mod component_changes;
|
||||
pub mod config;
|
||||
pub mod control_check;
|
||||
pub mod cra_requirements;
|
||||
pub mod csaf_docs;
|
||||
pub mod csaf_ingest;
|
||||
pub mod cve_groups;
|
||||
|
||||
@@ -28,6 +28,20 @@ pub struct AdvisoryRef {
|
||||
pub remediation: Option<String>,
|
||||
}
|
||||
|
||||
/// The providers whose terms ask every use of an advisory to link it.
|
||||
const BACKLINK_PROVIDERS: &[&str] = &["siemens"];
|
||||
|
||||
impl AdvisoryRef {
|
||||
/// The advisory's page when its provider's terms require a link back to
|
||||
/// it (Siemens ProductCERT); `None` otherwise. The views link nothing
|
||||
/// else off-site: a customer copies the id instead.
|
||||
pub fn required_backlink(&self) -> Option<&str> {
|
||||
self.url
|
||||
.as_deref()
|
||||
.filter(|_| BACKLINK_PROVIDERS.contains(&self.provider.as_str()))
|
||||
}
|
||||
}
|
||||
|
||||
/// What is known about the exploitation of one CVE (#493), from public
|
||||
/// sources: CISA's Known Exploited Vulnerabilities catalog, FIRST's EPSS and
|
||||
/// CISA's Vulnrichment SSVC decision points.
|
||||
@@ -209,13 +223,30 @@ impl CveAlert {
|
||||
ids
|
||||
}
|
||||
|
||||
/// Whether a VEX statement settles the alert: `not_affected` or `fixed`,
|
||||
/// stated by a person, by the scan or in an imported VEX document. Such an
|
||||
/// alert raises no notification and keeps no open tracker issue; once the
|
||||
/// statement is withdrawn (back to `affected`, `under_investigation` or
|
||||
/// none) it counts again.
|
||||
/// The alert's VEX statement, by a person, by a scan from the target's
|
||||
/// own data or in an imported VEX document. A `fixed` a scan inferred
|
||||
/// from the CVE no longer being found is none
|
||||
/// ([`super::vex::VexAssessment::is_inferred_from_absence`], #994).
|
||||
pub fn statement(&self) -> Option<&super::vex::VexAssessment> {
|
||||
self.vex
|
||||
.as_ref()
|
||||
.filter(|vex| !vex.is_inferred_from_absence())
|
||||
}
|
||||
|
||||
/// Drop a `fixed` inferred from absence (see [`Self::statement`]), so a
|
||||
/// client shown the stored alert does not read it as a statement.
|
||||
pub fn drop_inferred_fix(&mut self) {
|
||||
if self.statement().is_none() {
|
||||
self.vex = None;
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a VEX statement ([`Self::statement`]) settles the alert:
|
||||
/// `not_affected` or `fixed`. Such an alert raises no notification and
|
||||
/// keeps no open tracker issue; once the statement is withdrawn (back to
|
||||
/// `affected`, `under_investigation` or none) it counts again.
|
||||
pub fn is_resolved_by_vex(&self) -> bool {
|
||||
self.vex.as_ref().is_some_and(|vex| vex.status.resolves())
|
||||
self.statement().is_some_and(|vex| vex.status.resolves())
|
||||
}
|
||||
|
||||
pub fn new(
|
||||
@@ -267,6 +298,31 @@ mod tests {
|
||||
a
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_a_provider_that_asks_for_it_keeps_its_link() {
|
||||
let advisory = |provider: &str| AdvisoryRef {
|
||||
provider: provider.into(),
|
||||
id: "X-1".into(),
|
||||
title: "t".into(),
|
||||
url: Some("https://vendor.example/x-1".into()),
|
||||
remediation: None,
|
||||
};
|
||||
assert_eq!(
|
||||
advisory("siemens").required_backlink(),
|
||||
Some("https://vendor.example/x-1")
|
||||
);
|
||||
assert_eq!(advisory("codesys").required_backlink(), None);
|
||||
assert_eq!(
|
||||
advisory("supplier:https://s.example/pm.json").required_backlink(),
|
||||
None
|
||||
);
|
||||
let unlinked = AdvisoryRef {
|
||||
url: None,
|
||||
..advisory("siemens")
|
||||
};
|
||||
assert_eq!(unlinked.required_backlink(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_not_affected_and_fixed_resolve_an_alert() {
|
||||
use crate::models::vex::{VexAssessment, VexStatus};
|
||||
@@ -292,6 +348,35 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_fixed_inferred_from_absence_is_no_statement() {
|
||||
use crate::models::vex::{VexAssessment, VexStatus};
|
||||
let scan_fixed = |impact_statement: Option<&str>| VexAssessment {
|
||||
status: VexStatus::Fixed,
|
||||
justification: None,
|
||||
impact_statement: impact_statement.map(String::from),
|
||||
action_statement: None,
|
||||
by: "pruefwerk-scan".into(),
|
||||
by_name: None,
|
||||
at: Utc::now(),
|
||||
by_scan: true,
|
||||
};
|
||||
// What scans stated for a CVE they no longer found (#994).
|
||||
let mut a = alert("CVE-2021-44228", &[]);
|
||||
a.vex = Some(scan_fixed(None));
|
||||
assert!(a.statement().is_none());
|
||||
assert!(!a.is_resolved_by_vex());
|
||||
a.drop_inferred_fix();
|
||||
assert!(a.vex.is_none());
|
||||
// A Yocto recipe's patch gives its reason: a statement.
|
||||
let recipe = scan_fixed(Some("Patched in the recipe (CVE: tag)."));
|
||||
a.vex = Some(recipe.clone());
|
||||
assert_eq!(a.statement(), Some(&recipe));
|
||||
assert!(a.is_resolved_by_vex());
|
||||
a.drop_inferred_fix();
|
||||
assert_eq!(a.vex, Some(recipe));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_cve_is_strictly_recognised() {
|
||||
assert!(is_cve("CVE-2021-44228"));
|
||||
|
||||
@@ -98,6 +98,15 @@ pub struct TrackerIssue {
|
||||
/// closed: a person's decision the scan does not undo on its own.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub closed_in_tracker: Option<String>,
|
||||
/// When a complete scan first no longer found the issue's CVE (#994),
|
||||
/// while it stays gone: the issue was told so once and stays open, since
|
||||
/// a CVE that is gone is no proof of a fix.
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "super::serde_helpers::opt_bson_datetime"
|
||||
)]
|
||||
pub gone_noted_at: Option<DateTime<Utc>>,
|
||||
#[serde(with = "super::serde_helpers::bson_datetime")]
|
||||
pub created_at: DateTime<Utc>,
|
||||
#[serde(with = "super::serde_helpers::bson_datetime")]
|
||||
@@ -122,6 +131,7 @@ impl TrackerIssue {
|
||||
title,
|
||||
status: IssueStatus::Open,
|
||||
closed_in_tracker: None,
|
||||
gone_noted_at: None,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
}
|
||||
|
||||
@@ -89,7 +89,9 @@ pub struct VexAssessment {
|
||||
pub by_name: Option<String>,
|
||||
#[serde(with = "super::serde_helpers::bson_datetime")]
|
||||
pub at: DateTime<Utc>,
|
||||
/// Set by a scan (a `fixed` because the component is gone), not a person.
|
||||
/// Set by a scan from the target's own data (a Yocto recipe's
|
||||
/// `CVE_STATUS` or patch), not a person. Before #994 also a `fixed` for
|
||||
/// a CVE a scan no longer found ([`Self::is_inferred_from_absence`]).
|
||||
#[serde(default)]
|
||||
pub by_scan: bool,
|
||||
}
|
||||
@@ -142,6 +144,16 @@ pub enum VexError {
|
||||
}
|
||||
|
||||
impl VexAssessment {
|
||||
/// Whether this is a `fixed` that a scan stated only because a complete
|
||||
/// scan no longer found the CVE, as scans did before #994. A CVE can
|
||||
/// disappear without a fix (other scan data, an incomplete inventory, a
|
||||
/// changed identification), so nothing reads such a statement as one. A
|
||||
/// scan's statement from the target's own data always gives its reason
|
||||
/// (`impact_statement`), so it is never one of them.
|
||||
pub fn is_inferred_from_absence(&self) -> bool {
|
||||
self.by_scan && self.status == VexStatus::Fixed && self.impact_statement.is_none()
|
||||
}
|
||||
|
||||
/// Check what OpenVEX requires of a statement: a reason for
|
||||
/// `not_affected`, and (stricter than OpenVEX, as CISA recommends) an
|
||||
/// action for `affected`.
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
//! known vulnerability of its components, in OpenVEX 0.2.0 and in CycloneDX
|
||||
//! 1.6 (the SBOM with its vulnerabilities and their analysis).
|
||||
//!
|
||||
//! An alert nobody assessed is `under_investigation`; one a complete scan no
|
||||
//! longer finds is `fixed`. The CycloneDX analysis uses CycloneDX's terms:
|
||||
//! An alert nobody assessed is `under_investigation`, also when a complete
|
||||
//! scan no longer finds it: a CVE can disappear without a fix, so only a
|
||||
//! statement says `fixed` (#994). The CycloneDX analysis uses CycloneDX's
|
||||
//! terms:
|
||||
//!
|
||||
//! | OpenVEX | CycloneDX |
|
||||
//! |---|---|
|
||||
@@ -42,14 +44,13 @@ pub struct VexInput<'a> {
|
||||
pub now: DateTime<Utc>,
|
||||
}
|
||||
|
||||
/// The status an alert is stated with: its VEX statement's, `fixed` once a
|
||||
/// complete scan found it gone, else `under_investigation`.
|
||||
/// The status an alert is stated with: its VEX statement's
|
||||
/// ([`CveAlert::statement`]), else `under_investigation`. A CVE a complete
|
||||
/// scan no longer finds is not thereby `fixed` (#994).
|
||||
pub fn status_of(alert: &CveAlert) -> VexStatus {
|
||||
match (&alert.vex, alert.resolved_at) {
|
||||
(Some(vex), _) => vex.status,
|
||||
(None, Some(_)) => VexStatus::Fixed,
|
||||
(None, None) => VexStatus::UnderInvestigation,
|
||||
}
|
||||
alert
|
||||
.statement()
|
||||
.map_or(VexStatus::UnderInvestigation, |vex| vex.status)
|
||||
}
|
||||
|
||||
/// The SBOM entry an alert is about, if it is in the SBOM.
|
||||
@@ -105,10 +106,7 @@ impl Statement<'_> {
|
||||
/// the same component: an explicit statement (the latest one) over none,
|
||||
/// then an open alert over a resolved one.
|
||||
fn weight(alert: &CveAlert) -> (Option<DateTime<Utc>>, bool) {
|
||||
(
|
||||
alert.vex.as_ref().map(|v| v.at),
|
||||
alert.resolved_at.is_none(),
|
||||
)
|
||||
(alert.statement().map(|v| v.at), alert.resolved_at.is_none())
|
||||
}
|
||||
|
||||
/// The statements of `input`, one per CVE and component in the order the
|
||||
@@ -169,7 +167,7 @@ pub fn openvex(input: &VexInput<'_>) -> serde_json::Value {
|
||||
}],
|
||||
"status": status,
|
||||
});
|
||||
if let Some(vex) = &alert.vex {
|
||||
if let Some(vex) = alert.statement() {
|
||||
statement["timestamp"] = serde_json::json!(rfc3339(vex.at));
|
||||
if let Some(j) = vex.justification {
|
||||
statement["justification"] = serde_json::json!(j);
|
||||
@@ -253,7 +251,7 @@ pub fn cyclonedx_vex(input: &VexInput<'_>) -> serde_json::Value {
|
||||
}
|
||||
let status = status_of(alert);
|
||||
let mut analysis = serde_json::json!({ "state": cdx_state(status) });
|
||||
if let Some(vex) = &alert.vex {
|
||||
if let Some(vex) = alert.statement() {
|
||||
if let Some(j) = vex.justification {
|
||||
analysis["justification"] = serde_json::json!(cdx_justification(j));
|
||||
}
|
||||
|
||||
@@ -111,12 +111,13 @@ fn alerts() -> Vec<CveAlert> {
|
||||
s.justification = Some(VexJustification::VulnerableCodeNotInExecutePath);
|
||||
s.impact_statement = Some("template() is never called.".into());
|
||||
not_affected.vex = Some(s);
|
||||
let mut gone = alert("CVE-2020-0001", "zlib", "1.2.11");
|
||||
gone.resolved_at = Some(Utc::now());
|
||||
let mut fixed = alert("CVE-2020-0001", "zlib", "1.2.11");
|
||||
fixed.resolved_at = Some(Utc::now());
|
||||
fixed.vex = Some(statement(VexStatus::Fixed));
|
||||
vec![
|
||||
affected,
|
||||
not_affected,
|
||||
gone,
|
||||
fixed,
|
||||
alert("CVE-2024-0002", "PumpSDK", "3.1.0"),
|
||||
]
|
||||
}
|
||||
@@ -412,8 +413,10 @@ fn a_fixed_component_that_left_the_sbom_keeps_its_stored_purl() {
|
||||
let mut log4j = alert("CVE-2021-44228", "log4j-core", "2.14.1");
|
||||
log4j.purl = Some(maven.into());
|
||||
log4j.resolved_at = Some(Utc::now());
|
||||
log4j.vex = Some(statement(VexStatus::Fixed));
|
||||
let mut old = alert("CVE-2020-0001", "zlib", "1.2.11");
|
||||
old.resolved_at = Some(Utc::now());
|
||||
old.vex = Some(statement(VexStatus::Fixed));
|
||||
let alerts = vec![log4j, old];
|
||||
let input = vex_input(&alerts, &sbom);
|
||||
|
||||
@@ -597,3 +600,38 @@ fn the_cyclonedx_sbom_lists_a_vulnerability_under_its_cve_once() {
|
||||
assert_eq!(vulns[1]["source"]["name"], "osv");
|
||||
assert!(vulns[1].get("references").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_cve_a_scan_no_longer_finds_is_not_stated_fixed() {
|
||||
// Arrange (#994): one alert gone without a statement (Weg B), one with
|
||||
// the `fixed` scans inferred from that before (Weg A).
|
||||
let mut unstated = alert("CVE-2020-0001", "zlib", "1.2.11");
|
||||
unstated.resolved_at = Some(Utc::now());
|
||||
let mut inferred = alert("CVE-2021-44228", "log4j-core", "2.14.1");
|
||||
inferred.resolved_at = Some(Utc::now());
|
||||
inferred.vex = Some(VexAssessment {
|
||||
by: "pruefwerk-scan".into(),
|
||||
by_name: None,
|
||||
by_scan: true,
|
||||
..statement(VexStatus::Fixed)
|
||||
});
|
||||
let (alerts, sbom) = (vec![unstated, inferred], sbom());
|
||||
let input = vex_input(&alerts, &sbom);
|
||||
|
||||
// Act
|
||||
let openvex = vex_docs::openvex(&input);
|
||||
let cdx = vex_docs::cyclonedx_vex(&input);
|
||||
let csaf = csaf_docs::csaf_vex(&input, "https://example.invalid/pumps", "en");
|
||||
|
||||
// Assert: under investigation in every format, never fixed.
|
||||
assert_eq!(openvex_errors(&openvex), Vec::<String>::new());
|
||||
assert_eq!(cyclonedx_errors(&cdx), Vec::<String>::new());
|
||||
assert_eq!(csaf_errors(&csaf), Vec::<String>::new());
|
||||
for i in 0..2 {
|
||||
assert_eq!(openvex["statements"][i]["status"], "under_investigation");
|
||||
assert_eq!(cdx["vulnerabilities"][i]["analysis"]["state"], "in_triage");
|
||||
let status = &csaf["vulnerabilities"][i]["product_status"];
|
||||
assert!(status["fixed"].is_null(), "{status}");
|
||||
assert!(status["under_investigation"].is_array(), "{status}");
|
||||
}
|
||||
}
|
||||
@@ -884,6 +884,12 @@ tbody tr:last-child td {
|
||||
}
|
||||
|
||||
/* Neutral: skipped because a feature is disabled in this environment — not an error. */
|
||||
.badge-open {
|
||||
background: var(--bg-elevated);
|
||||
color: var(--text-secondary);
|
||||
border: 1px dashed var(--text-faint);
|
||||
}
|
||||
|
||||
.badge-neutral {
|
||||
background: transparent;
|
||||
color: var(--text-tertiary);
|
||||
@@ -2955,18 +2961,6 @@ tbody tr:last-child td {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.sbom-vuln-link {
|
||||
font-size: 12px;
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
transition: color 0.15s;
|
||||
}
|
||||
|
||||
.sbom-vuln-link:hover {
|
||||
color: var(--accent-hover);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* License compliance */
|
||||
.sbom-license-badge {
|
||||
font-size: 12px;
|
||||
@@ -4243,9 +4237,7 @@ tbody tr:last-child td {
|
||||
.notification-sev.sev-high { background: rgba(255,140,0,0.12); color: #ff8c00; }
|
||||
.notification-sev.sev-medium { background: var(--warning-bg); color: var(--warning); }
|
||||
.notification-sev.sev-low { background: rgba(0,200,255,0.08); color: var(--accent); }
|
||||
.notification-cve-id { font-size: 12px; font-weight: 600; color: var(--text-primary); font-family: var(--font-mono); }
|
||||
.notification-cve-id a { color: var(--accent); text-decoration: none; }
|
||||
.notification-cve-id a:hover { text-decoration: underline; }
|
||||
.notification-cve-id { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-primary); font-family: var(--font-mono); }
|
||||
.notification-cvss { font-size: 10px; color: var(--text-secondary); margin-left: auto; font-family: var(--font-mono); }
|
||||
.notification-dismiss-btn { background: none; border: none; color: var(--text-tertiary); cursor: pointer; padding: 2px; margin-left: 4px; }
|
||||
.notification-dismiss-btn:hover { color: var(--danger); }
|
||||
@@ -4482,6 +4474,17 @@ tbody tr:last-child td {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.finding-control {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: var(--accent-muted);
|
||||
color: var(--text-primary);
|
||||
font-size: 12px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.finding-controls-more,
|
||||
.finding-controls-none {
|
||||
font-size: 11px;
|
||||
@@ -4492,7 +4495,8 @@ tbody tr:last-child td {
|
||||
.finding-refs {
|
||||
list-style: none;
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
justify-items: start;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.finding-refs-catalog {
|
||||
@@ -4582,8 +4586,8 @@ tbody tr:last-child td {
|
||||
}
|
||||
|
||||
.cra-violated { background: var(--danger); }
|
||||
.cra-open { background: var(--warning); }
|
||||
.cra-partial { background: var(--info); }
|
||||
.cra-open { background: var(--text-faint); }
|
||||
.cra-partial { background: var(--warning); }
|
||||
.cra-clear { background: var(--success); }
|
||||
.cra-process { background: color-mix(in srgb, var(--accent) 28%, var(--bg-elevated)); }
|
||||
|
||||
@@ -5585,7 +5589,20 @@ tbody tr:last-child td {
|
||||
}
|
||||
|
||||
.vex-advisory {
|
||||
display: block;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11.5px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.vex-cve-id,
|
||||
.vex-advisory-line {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px 6px;
|
||||
}
|
||||
|
||||
.vex-advisory-source {
|
||||
font-size: 11.5px;
|
||||
color: var(--accent);
|
||||
}
|
||||
@@ -5742,13 +5759,6 @@ tbody tr:last-child td {
|
||||
gap: 6px 10px;
|
||||
}
|
||||
|
||||
.cra-control-id {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11.5px;
|
||||
color: var(--text-tertiary);
|
||||
min-width: 72px;
|
||||
}
|
||||
|
||||
.cra-control-title {
|
||||
font-weight: 500;
|
||||
}
|
||||
@@ -5759,7 +5769,6 @@ tbody tr:last-child td {
|
||||
}
|
||||
|
||||
.cra-control-reason {
|
||||
padding-left: 82px;
|
||||
font-size: 12.5px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
@@ -5768,7 +5777,6 @@ tbody tr:last-child td {
|
||||
list-style: none;
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
padding-left: 82px;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
|
||||
@@ -8062,14 +8070,18 @@ span.repo-crumb-name {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
/* ── CRA Annex I tiles (#957) ── */
|
||||
/* ── CRA Annex I map (#957): requirements by name, grouped by area ── */
|
||||
.ct-card,
|
||||
.sh-card {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.ct-head,
|
||||
.ct-head {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.sh-head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -8084,7 +8096,6 @@ span.repo-crumb-name {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.ct-legend,
|
||||
.sh-legend {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -8093,97 +8104,250 @@ span.repo-crumb-name {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.ct-legend-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.ct-swatch {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 20px;
|
||||
height: 16px;
|
||||
padding: 0 3px;
|
||||
border-radius: 3px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* Ten to a row, as the 40 requirements make four rows; five on a phone. */
|
||||
.ct-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(10, minmax(0, 1fr));
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.ct-grid {
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
.ct-tile {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
min-height: 56px;
|
||||
padding: 6px 8px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--radius);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.ct-tile:hover,
|
||||
.ct-tile:focus-visible {
|
||||
outline: 2px solid var(--text-primary);
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
.ct-tile-mark {
|
||||
align-self: flex-end;
|
||||
font-family: var(--font-body);
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* A state's colour, always with its sign beside it. */
|
||||
.ct-ok { background: var(--success); color: #fff; }
|
||||
.ct-bad { background: var(--danger); color: #fff; }
|
||||
.ct-open { background: var(--warning-bg); border-color: var(--border-bright); color: var(--text-primary); }
|
||||
.ct-partial { background: var(--info-bg); border-color: var(--border-bright); color: var(--text-primary); }
|
||||
.ct-process { background: var(--bg-elevated); border-color: var(--border-bright); color: var(--text-secondary); }
|
||||
|
||||
.ct-hint,
|
||||
.sh-hint {
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12.5px;
|
||||
}
|
||||
|
||||
.ct-crumbs {
|
||||
/* The areas beside the open requirement; the panel goes below on a phone. */
|
||||
.ct-layout {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.ct-crumbs a {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.ct-back {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.ct-detail {
|
||||
.ct-areas {
|
||||
flex: 999 1 560px;
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.ct-area {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
background: var(--bg-card);
|
||||
}
|
||||
|
||||
.ct-area-name {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.ct-area-bar {
|
||||
height: 6px;
|
||||
}
|
||||
|
||||
.ct-chips {
|
||||
list-style: none;
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
/* A requirement: its state's sign, its name, and its open findings. */
|
||||
.ct-chip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-height: 44px;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--radius);
|
||||
color: var(--text-primary);
|
||||
font-size: 13.5px;
|
||||
font-weight: 500;
|
||||
line-height: 1.3;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.ct-chip:hover {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.ct-chip:focus-visible,
|
||||
.ct-chip.is-selected {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.ct-chip-name {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.ct-chip-n {
|
||||
flex-shrink: 0;
|
||||
min-width: 22px;
|
||||
height: 22px;
|
||||
padding: 0 6px;
|
||||
border-radius: 11px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--bg-card);
|
||||
color: var(--danger);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.ct-chip.ct-ok { background: var(--success-bg); }
|
||||
.ct-chip.ct-unknown { border-color: var(--border-bright); }
|
||||
.ct-chip.ct-bad { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
|
||||
.ct-chip.ct-partial { background: var(--warning-bg); border-color: var(--warning); }
|
||||
.ct-chip.ct-open { background: var(--bg-elevated); border: 1px dashed var(--text-faint); color: var(--text-secondary); }
|
||||
.ct-chip.ct-process { background: transparent; border: 1px dotted var(--text-faint); color: var(--text-secondary); }
|
||||
|
||||
/* A state's sign in a round mark: never colour alone. */
|
||||
.ct-mark {
|
||||
flex-shrink: 0;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.ct-mark.ct-ok { background: var(--success); color: #fff; }
|
||||
.ct-mark.ct-bad { background: var(--danger); color: #fff; }
|
||||
.ct-mark.ct-partial { background: var(--warning); color: #fff; }
|
||||
.ct-mark.ct-open { background: var(--bg-elevated); border: 1px dashed var(--text-faint); color: var(--text-secondary); }
|
||||
.ct-mark.ct-process { background: var(--bg-card); border: 1px dotted var(--text-faint); color: var(--text-secondary); }
|
||||
.ct-chip.ct-bad .ct-mark { background: #fff; color: var(--danger); }
|
||||
|
||||
/* The open requirement. */
|
||||
.ct-panel {
|
||||
flex: 1 1 320px;
|
||||
min-width: 0;
|
||||
max-width: 440px;
|
||||
display: grid;
|
||||
align-content: start;
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
background: var(--bg-card);
|
||||
}
|
||||
|
||||
/* Where the map and panel no longer fit side by side, the panel goes first,
|
||||
so the requirement a tap opens is not below all forty. */
|
||||
@media (max-width: 1200px) {
|
||||
.ct-panel {
|
||||
order: -1;
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
.ct-panel-empty {
|
||||
color: var(--text-tertiary);
|
||||
font-size: 13.5px;
|
||||
}
|
||||
|
||||
.ct-panel-head {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.ct-panel-area {
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12.5px;
|
||||
}
|
||||
|
||||
.ct-panel-name {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.ct-panel-state {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.ct-panel-what {
|
||||
color: var(--text-secondary);
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.ct-meanings,
|
||||
.ct-proof {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.ct-meanings h4,
|
||||
.ct-proof h4 {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.ct-meanings ul {
|
||||
list-style: none;
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.ct-meaning {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
font-size: 13.5px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.ct-meaning div {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.ct-meaning span {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.ct-meaning.is-now {
|
||||
border-color: var(--accent);
|
||||
background: var(--bg-card-hover);
|
||||
}
|
||||
|
||||
.ct-proof {
|
||||
padding: 12px;
|
||||
border: 1px dotted var(--text-faint);
|
||||
border-radius: var(--radius);
|
||||
font-size: 13.5px;
|
||||
line-height: 1.45;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.ct-panel-detail:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ct-panel-detail .cra-control {
|
||||
padding-top: 0;
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.ct-panel-links {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 16px;
|
||||
}
|
||||
|
||||
/* ── Verlauf: per scan, new CVEs above the line, gone below (#957) ── */
|
||||
.sh-swatch {
|
||||
display: inline-block;
|
||||
@@ -8402,10 +8566,6 @@ span.repo-crumb-name {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.vex-advisory-line .vex-advisory {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.vex-advisory-note {
|
||||
font-size: 11px;
|
||||
color: var(--text-tertiary);
|
||||
|
||||
@@ -2,12 +2,22 @@ use dioxus::prelude::*;
|
||||
use dioxus_free_icons::icons::bs_icons::*;
|
||||
use dioxus_free_icons::Icon;
|
||||
|
||||
use crate::i18n::texts::common;
|
||||
use crate::i18n::use_lang;
|
||||
|
||||
/// A small copy-to-clipboard button that shows a checkmark after copying.
|
||||
///
|
||||
/// Usage: `CopyButton { value: "text to copy" }`
|
||||
#[component]
|
||||
pub fn CopyButton(value: String, #[props(default = false)] small: bool) -> Element {
|
||||
let lang = use_lang()();
|
||||
let mut copied = use_signal(|| false);
|
||||
let label = if copied() {
|
||||
common::COPIED
|
||||
} else {
|
||||
common::COPY
|
||||
};
|
||||
let tip = format!("{}: {value}", label.get(lang));
|
||||
|
||||
let size = if small { 12 } else { 14 };
|
||||
let class = if small {
|
||||
@@ -19,7 +29,9 @@ pub fn CopyButton(value: String, #[props(default = false)] small: bool) -> Eleme
|
||||
rsx! {
|
||||
button {
|
||||
class: class,
|
||||
title: if copied() { "Copied!" } else { "Copy to clipboard" },
|
||||
r#type: "button",
|
||||
title: "{tip}",
|
||||
"aria-label": "{tip}",
|
||||
onclick: move |_| {
|
||||
let val = value.clone();
|
||||
// Escape for JS single-quoted string
|
||||
|
||||
@@ -1,37 +1,90 @@
|
||||
//! The CRA Annex I view of a target (#957): its 40 requirements as tiles,
|
||||
//! coloured by state and marked with a sign, so the state is never told by
|
||||
//! colour alone. A tile opens the requirement with what its state rests on.
|
||||
//! The CRA Annex I view of a target (#957): its 40 requirements by name,
|
||||
//! grouped by area, each marked with its state's colour and sign so the
|
||||
//! state is never told by colour alone. A requirement opens beside the map
|
||||
//! with what its colour means for it and what the state rests on.
|
||||
|
||||
use compliance_core::cra_requirements::{self as cra, CraArea, CraRequirement};
|
||||
use dioxus::prelude::*;
|
||||
|
||||
use crate::app::Route;
|
||||
use crate::components::cra_bar::CraBar;
|
||||
use crate::i18n::texts::{common, compliance, cra_tiles as tx};
|
||||
use crate::i18n::use_lang;
|
||||
use crate::infrastructure::evidence::fetch_compliance;
|
||||
use crate::pages::compliance::{ControlRow, STATES};
|
||||
use crate::i18n::{use_lang, Lang, Text};
|
||||
use crate::infrastructure::evidence::{fetch_compliance, CraCounts};
|
||||
use crate::pages::compliance::{requirement_name, ControlRow, STATES};
|
||||
use crate::pages::target_views::RepoView;
|
||||
|
||||
/// A tile's sign and CSS tone for a control `state` (as the API names it).
|
||||
/// A state's sign (an SVG path) and CSS tone, for a control `state` as the
|
||||
/// API names it.
|
||||
fn mark(state: &str) -> (&'static str, &'static str) {
|
||||
match state {
|
||||
"not_satisfied" => ("!", "ct-bad"),
|
||||
"not_assessed" => ("?", "ct-open"),
|
||||
"partial" => ("~", "ct-partial"),
|
||||
"no_violation_found" => ("OK", "ct-ok"),
|
||||
_ => ("–", "ct-process"),
|
||||
"not_satisfied" => ("M12 5v9M12 19v.5", "ct-bad"),
|
||||
"partial" => ("M5 12h14", "ct-partial"),
|
||||
"no_violation_found" => ("M5 12.5l4.5 4.5L19 7.5", "ct-ok"),
|
||||
"not_assessed" => ("M9 9a3 3 0 1 1 4 2.8c-.7.3-1 .9-1 1.7M12 18v.5", "ct-open"),
|
||||
_ => ("M7 4h7l4 4v12H7zM14 4v4h4M10 13h5M10 16h5", "ct-process"),
|
||||
}
|
||||
}
|
||||
|
||||
/// The short name a tile shows for control `id`: `cra-ai-7` is `AI-07`;
|
||||
/// another id stays as it is.
|
||||
fn short_id(id: &str) -> String {
|
||||
id.strip_prefix("cra-ai-")
|
||||
.and_then(|n| n.parse::<u32>().ok())
|
||||
.map_or_else(|| id.to_string(), |n| format!("AI-{n:02}"))
|
||||
/// The CSS tone of a requirement in `state`, or of one whose state is not
|
||||
/// known (`None`).
|
||||
pub(crate) fn cra_tone(state: Option<&str>) -> &'static str {
|
||||
state.map_or("ct-unknown", |s| mark(s).1)
|
||||
}
|
||||
|
||||
/// `controls` in tile order: by the number of their id, others last.
|
||||
fn in_tile_order(mut controls: Vec<serde_json::Value>) -> Vec<serde_json::Value> {
|
||||
/// The CraBar segment class of a control `state`, so an area's small bar
|
||||
/// uses the target bar's colours.
|
||||
fn bar_modifier(state: &str) -> &'static str {
|
||||
match state {
|
||||
"not_satisfied" => "violated",
|
||||
"not_assessed" => "open",
|
||||
"partial" => "partial",
|
||||
"no_violation_found" => "clear",
|
||||
_ => "process",
|
||||
}
|
||||
}
|
||||
|
||||
/// A state's label (`Offene Befunde`).
|
||||
fn state_label(state: &str, lang: Lang) -> &'static str {
|
||||
STATES
|
||||
.iter()
|
||||
.find(|(s, _, _)| *s == state)
|
||||
.map_or("", |(_, label, _)| label.get(lang))
|
||||
}
|
||||
|
||||
/// The sign of `state` in a round mark of its tone.
|
||||
#[component]
|
||||
pub(crate) fn StateMark(state: String) -> Element {
|
||||
let (path, tone) = mark(&state);
|
||||
rsx! {
|
||||
span { class: "ct-mark {tone}", "aria-hidden": "true",
|
||||
svg {
|
||||
width: "12",
|
||||
height: "12",
|
||||
view_box: "0 0 24 24",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
stroke_width: "3",
|
||||
stroke_linecap: "round",
|
||||
stroke_linejoin: "round",
|
||||
path { d: path }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One area of the map: the API's controls of that area, in id order.
|
||||
struct AreaControls {
|
||||
name: Text,
|
||||
controls: Vec<serde_json::Value>,
|
||||
}
|
||||
|
||||
/// `controls` (the compliance API's) grouped by area in the catalog's order;
|
||||
/// a control outside the 40 goes to a last group of its own.
|
||||
fn by_area(controls: &[serde_json::Value]) -> Vec<AreaControls> {
|
||||
let requirement = |c: &serde_json::Value| -> Option<&'static CraRequirement> {
|
||||
c["control"].as_str().and_then(cra::requirement)
|
||||
};
|
||||
let number = |c: &serde_json::Value| {
|
||||
c["control"]
|
||||
.as_str()
|
||||
@@ -39,12 +92,69 @@ fn in_tile_order(mut controls: Vec<serde_json::Value>) -> Vec<serde_json::Value>
|
||||
.and_then(|n| n.parse::<u32>().ok())
|
||||
.unwrap_or(u32::MAX)
|
||||
};
|
||||
controls.sort_by_key(number);
|
||||
controls
|
||||
let mut areas: Vec<AreaControls> = CraArea::ALL
|
||||
.iter()
|
||||
.map(|area| {
|
||||
let mut list: Vec<serde_json::Value> = controls
|
||||
.iter()
|
||||
.filter(|c| requirement(c).is_some_and(|r| r.area == *area))
|
||||
.cloned()
|
||||
.collect();
|
||||
list.sort_by_key(number);
|
||||
AreaControls {
|
||||
name: area.name().into(),
|
||||
controls: list,
|
||||
}
|
||||
})
|
||||
.filter(|a| !a.controls.is_empty())
|
||||
.collect();
|
||||
let others: Vec<serde_json::Value> = controls
|
||||
.iter()
|
||||
.filter(|c| requirement(c).is_none())
|
||||
.cloned()
|
||||
.collect();
|
||||
if !others.is_empty() {
|
||||
areas.push(AreaControls {
|
||||
name: tx::OTHER_AREA,
|
||||
controls: others,
|
||||
});
|
||||
}
|
||||
areas
|
||||
}
|
||||
|
||||
/// The tiles of target `target_id`, or, with `control` (from the URL) set,
|
||||
/// that requirement with its state, findings and reasons.
|
||||
/// The number of open findings `control` lists.
|
||||
fn finding_count(control: &serde_json::Value) -> usize {
|
||||
control["findings"].as_array().map_or(0, Vec::len)
|
||||
}
|
||||
|
||||
/// What the state of `control` means right now, in one sentence.
|
||||
fn state_sentence(control: &serde_json::Value, lang: Lang) -> String {
|
||||
let req = control["control"].as_str().and_then(cra::requirement);
|
||||
match control["state"].as_str().unwrap_or_default() {
|
||||
"not_satisfied" => {
|
||||
let against = req
|
||||
.and_then(|r| r.against)
|
||||
.map_or(tx::AGAINST_GENERIC, Text::from);
|
||||
format!(
|
||||
"{} {}",
|
||||
tx::against_count(finding_count(control), lang),
|
||||
against.get(lang)
|
||||
)
|
||||
}
|
||||
"no_violation_found" => req
|
||||
.and_then(|r| r.clear)
|
||||
.map_or(tx::CLEAR_GENERIC, Text::from)
|
||||
.get(lang)
|
||||
.to_string(),
|
||||
"partial" => Text::from(cra::PARTLY_CHECKED).get(lang).to_string(),
|
||||
"not_assessed" => compliance::not_assessed_reason(&control["reason"], lang)
|
||||
.unwrap_or_else(|| tx::OPEN_GENERIC.get(lang).to_string()),
|
||||
_ => tx::PROCESS_GENERIC.get(lang).to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The map of target `target_id`'s requirements, with `control` (from the
|
||||
/// URL) open beside it.
|
||||
#[component]
|
||||
pub fn CraTiles(target_id: String, control: Option<String>) -> Element {
|
||||
let lang = use_lang()();
|
||||
@@ -59,7 +169,9 @@ pub fn CraTiles(target_id: String, control: Option<String>) -> Element {
|
||||
let Some(data) = loaded else {
|
||||
return rsx! { div { class: "card", p { {tx::LOAD_FAILED.get(lang)} } } };
|
||||
};
|
||||
let controls = in_tile_order(data["controls"].as_array().cloned().unwrap_or_default());
|
||||
let controls = data["controls"].as_array().cloned().unwrap_or_default();
|
||||
let counts: CraCounts = serde_json::from_value(data["counts"].clone()).unwrap_or_default();
|
||||
let areas = by_area(&controls);
|
||||
let to_tile = |control: Option<String>| Route::TargetViewsPage {
|
||||
id: target_id.clone(),
|
||||
view: RepoView::Cra.slug().to_string(),
|
||||
@@ -68,96 +180,152 @@ pub fn CraTiles(target_id: String, control: Option<String>) -> Element {
|
||||
control,
|
||||
scan: None,
|
||||
};
|
||||
|
||||
if let Some(wanted) = control {
|
||||
let back = to_tile(None);
|
||||
let Some(chosen) = controls
|
||||
let chosen = control.as_ref().map(|wanted| {
|
||||
controls
|
||||
.iter()
|
||||
.find(|c| c["control"].as_str() == Some(wanted.as_str()))
|
||||
.cloned()
|
||||
else {
|
||||
return rsx! {
|
||||
div { class: "card",
|
||||
p { {tx::UNKNOWN.get(lang)} }
|
||||
Link { class: "repo-view-list", to: back, {tx::BACK.get(lang)} }
|
||||
}
|
||||
};
|
||||
};
|
||||
let state = chosen["state"].as_str().unwrap_or_default().to_string();
|
||||
let (label, badge) = STATES
|
||||
.iter()
|
||||
.find(|(s, _, _)| *s == state)
|
||||
.map_or(("", "badge"), |(_, label, badge)| (label.get(lang), *badge));
|
||||
return rsx! {
|
||||
nav { class: "ct-crumbs", "aria-label": tx::BREADCRUMB.get(lang),
|
||||
Link { to: back.clone(), "CRA" }
|
||||
span { "aria-hidden": "true", " › " }
|
||||
strong { "{short_id(&wanted)} {chosen[\"title\"].as_str().unwrap_or_default()}" }
|
||||
Link { class: "btn btn-sm btn-ghost ct-back", to: back, {tx::BACK.get(lang)} }
|
||||
}
|
||||
section { class: "card ct-detail",
|
||||
p { span { class: "{badge}", "{label}" } }
|
||||
ul { class: "cra-controls",
|
||||
ControlRow { control: chosen, lang, show_reason: true }
|
||||
}
|
||||
Link {
|
||||
class: "repo-view-list",
|
||||
to: Route::CompliancePage { id: target_id.clone() },
|
||||
{tx::ALL_REQUIREMENTS.get(lang)}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
rsx! {
|
||||
section { class: "card ct-card", "aria-label": tx::TITLE.get(lang),
|
||||
div { class: "ct-head",
|
||||
h3 { class: "ct-title", {tx::title(controls.len(), lang)} }
|
||||
div { class: "ct-legend",
|
||||
for (state, label, _) in STATES {
|
||||
{
|
||||
let (sign, tone) = mark(state);
|
||||
let n = controls.iter().filter(|c| c["state"].as_str() == Some(state)).count();
|
||||
rsx! {
|
||||
span { key: "{state}", class: "ct-legend-item",
|
||||
span { class: "ct-swatch {tone}", "aria-hidden": "true", "{sign}" }
|
||||
"{label.get(lang)} ({n})"
|
||||
CraBar { counts }
|
||||
p { class: "ct-hint", {compliance::NOT_LEGAL_ADVICE.get(lang)} }
|
||||
}
|
||||
div { class: "ct-layout",
|
||||
div { class: "ct-areas",
|
||||
for area in areas {
|
||||
section { class: "ct-area", "aria-label": area.name.get(lang),
|
||||
h4 { class: "ct-area-name", {area.name.get(lang)} }
|
||||
div { class: "cra-bar-track ct-area-bar", "aria-hidden": "true",
|
||||
for (state, _, _) in STATES {
|
||||
{
|
||||
let n = area.controls.iter().filter(|c| c["state"].as_str() == Some(state)).count();
|
||||
rsx! {
|
||||
if n > 0 {
|
||||
span { class: "cra-bar-seg cra-{bar_modifier(state)}", style: "flex: {n} 0 0;" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ul { class: "ct-chips",
|
||||
for c in area.controls.iter() {
|
||||
{
|
||||
let cid = c["control"].as_str().unwrap_or_default().to_string();
|
||||
let state = c["state"].as_str().unwrap_or_default().to_string();
|
||||
let (_, tone) = mark(&state);
|
||||
let selected = control.as_deref() == Some(cid.as_str());
|
||||
let n = finding_count(c);
|
||||
let name = requirement_name(c, lang);
|
||||
let label = state_label(&state, lang);
|
||||
rsx! {
|
||||
li { key: "{cid}",
|
||||
Link {
|
||||
class: if selected { "ct-chip {tone} is-selected" } else { "ct-chip {tone}" },
|
||||
"aria-current": if selected { "true" } else { "false" },
|
||||
to: to_tile(Some(cid.clone())),
|
||||
StateMark { state: state.clone() }
|
||||
span { class: "ct-chip-name", "{name}" }
|
||||
if n > 0 {
|
||||
span { class: "ct-chip-n", "{n}" }
|
||||
}
|
||||
span { class: "sr-only", ", {label}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
aside { class: "ct-panel", "aria-label": tx::SELECTED.get(lang),
|
||||
match chosen {
|
||||
None => rsx! { p { class: "ct-panel-empty", {tx::PICK.get(lang)} } },
|
||||
Some(None) => rsx! {
|
||||
p { {tx::UNKNOWN.get(lang)} }
|
||||
Link { class: "repo-view-list", to: to_tile(None), {tx::CLOSE.get(lang)} }
|
||||
},
|
||||
Some(Some(c)) => rsx! {
|
||||
RequirementPanel { control: c, lang, close: to_tile(None), all: Route::CompliancePage { id: target_id.clone() } }
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
div { class: "ct-grid",
|
||||
for c in controls.iter() {
|
||||
{
|
||||
let id = c["control"].as_str().unwrap_or_default().to_string();
|
||||
let state = c["state"].as_str().unwrap_or_default();
|
||||
let (sign, tone) = mark(state);
|
||||
let state_label = STATES
|
||||
.iter()
|
||||
.find(|(s, _, _)| *s == state)
|
||||
.map_or("", |(_, label, _)| label.get(lang));
|
||||
let tip = format!(
|
||||
"{}: {} ({state_label})",
|
||||
short_id(&id),
|
||||
c["title"].as_str().unwrap_or_default()
|
||||
);
|
||||
rsx! {
|
||||
Link {
|
||||
key: "{id}",
|
||||
class: "ct-tile {tone}",
|
||||
title: "{tip}",
|
||||
"aria-label": "{tip}",
|
||||
to: to_tile(Some(id.clone())),
|
||||
span { class: "ct-tile-id", "{short_id(&id)}" }
|
||||
span { class: "ct-tile-mark", "{sign}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The open requirement: its name and state, what each colour means for it
|
||||
/// (or the document that proves it), and what its state rests on.
|
||||
#[component]
|
||||
fn RequirementPanel(control: serde_json::Value, lang: Lang, close: Route, all: Route) -> Element {
|
||||
let req = control["control"].as_str().and_then(cra::requirement);
|
||||
let state = control["state"].as_str().unwrap_or_default().to_string();
|
||||
let area = req.map(|r| Text::from(r.area.name()).get(lang));
|
||||
let name = requirement_name(&control, lang);
|
||||
let sentence = state_sentence(&control, lang);
|
||||
// Red, orange, green: what each would mean for this requirement.
|
||||
let meanings: Vec<(&str, Text, Text)> = req
|
||||
.and_then(|r| r.against.zip(r.clear))
|
||||
.map(|(against, clear)| {
|
||||
vec![
|
||||
("not_satisfied", tx::RED, against.into()),
|
||||
("partial", tx::ORANGE, cra::PARTLY_CHECKED.into()),
|
||||
("no_violation_found", tx::GREEN, clear.into()),
|
||||
]
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let proof = req.and_then(|r| r.proof).map(Text::from);
|
||||
|
||||
rsx! {
|
||||
div { class: "ct-panel-head",
|
||||
if let Some(area) = area {
|
||||
span { class: "ct-panel-area", "{area}" }
|
||||
}
|
||||
h3 { class: "ct-panel-name", "{name}" }
|
||||
p { class: "ct-panel-state",
|
||||
StateMark { state: state.clone() }
|
||||
strong { {state_label(&state, lang)} }
|
||||
}
|
||||
p { class: "ct-panel-what", "{sentence}" }
|
||||
}
|
||||
if !meanings.is_empty() {
|
||||
div { class: "ct-meanings",
|
||||
h4 { {tx::MEANINGS.get(lang)} }
|
||||
ul {
|
||||
for (meaning_state, colour, text) in meanings {
|
||||
li { class: if meaning_state == state { "ct-meaning is-now" } else { "ct-meaning" },
|
||||
StateMark { state: meaning_state.to_string() }
|
||||
div {
|
||||
strong {
|
||||
{colour.get(lang)}
|
||||
if meaning_state == state {
|
||||
{tx::NOW.get(lang)}
|
||||
}
|
||||
}
|
||||
span { {text.get(lang)} }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
p { class: "ct-hint", {tx::HINT.get(lang)} " " {compliance::NOT_LEGAL_ADVICE.get(lang)} }
|
||||
}
|
||||
if let Some(proof) = proof {
|
||||
div { class: "ct-proof",
|
||||
h4 { {tx::PROOF_TITLE.get(lang)} }
|
||||
p { {tx::proof(proof.get(lang), lang)} }
|
||||
}
|
||||
}
|
||||
ul { class: "cra-controls ct-panel-detail",
|
||||
ControlRow { control, lang, show_reason: false, headless: true }
|
||||
}
|
||||
div { class: "ct-panel-links",
|
||||
Link { class: "repo-view-list", to: close, {tx::CLOSE.get(lang)} }
|
||||
Link { class: "repo-view-list", to: all, {tx::ALL_REQUIREMENTS.get(lang)} }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,25 +335,60 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_tile_names_its_requirement_short_and_in_number_order() {
|
||||
assert_eq!(short_id("cra-ai-7"), "AI-07");
|
||||
assert_eq!(short_id("cra-ai-40"), "AI-40");
|
||||
assert_eq!(short_id("custom"), "custom");
|
||||
let ordered = in_tile_order(vec![
|
||||
serde_json::json!({ "control": "cra-ai-10" }),
|
||||
serde_json::json!({ "control": "other" }),
|
||||
serde_json::json!({ "control": "cra-ai-2" }),
|
||||
]);
|
||||
let ids: Vec<&str> = ordered
|
||||
fn controls_are_grouped_by_area_in_id_order() {
|
||||
let controls = vec![
|
||||
serde_json::json!({ "control": "cra-ai-9" }),
|
||||
serde_json::json!({ "control": "custom" }),
|
||||
serde_json::json!({ "control": "cra-ai-7" }),
|
||||
serde_json::json!({ "control": "cra-ai-1" }),
|
||||
];
|
||||
let areas = by_area(&controls);
|
||||
let ids: Vec<Vec<&str>> = areas
|
||||
.iter()
|
||||
.filter_map(|c| c["control"].as_str())
|
||||
.map(|a| {
|
||||
a.controls
|
||||
.iter()
|
||||
.filter_map(|c| c["control"].as_str())
|
||||
.collect()
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(ids, ["cra-ai-2", "cra-ai-10", "other"]);
|
||||
assert_eq!(
|
||||
ids,
|
||||
[
|
||||
vec!["cra-ai-1"],
|
||||
vec!["cra-ai-7", "cra-ai-9"],
|
||||
vec!["custom"]
|
||||
]
|
||||
);
|
||||
assert_eq!(areas[0].name.de, "Sicher entworfen");
|
||||
assert_eq!(areas[2].name, tx::OTHER_AREA);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_state_has_its_own_sign() {
|
||||
let signs: Vec<&str> = STATES.iter().map(|(s, _, _)| mark(s).0).collect();
|
||||
assert_eq!(signs, ["!", "?", "~", "OK", "–"]);
|
||||
let mut signs: Vec<&str> = STATES.iter().map(|(s, _, _)| mark(s).0).collect();
|
||||
signs.sort_unstable();
|
||||
signs.dedup();
|
||||
assert_eq!(signs.len(), STATES.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_sentence_says_what_the_state_means_for_the_requirement() {
|
||||
let red = serde_json::json!({
|
||||
"control": "cra-ai-8", "state": "not_satisfied",
|
||||
"findings": [{ "id": "a" }, { "id": "b" }],
|
||||
});
|
||||
let text = state_sentence(&red, Lang::De);
|
||||
assert!(text.starts_with("2 offene Befunde"), "{text}");
|
||||
assert!(text.contains("fest eingebautes Passwort"), "{text}");
|
||||
|
||||
let green = serde_json::json!({ "control": "cra-ai-8", "state": "no_violation_found" });
|
||||
assert_eq!(
|
||||
state_sentence(&green, Lang::En),
|
||||
"The scan found no built-in password."
|
||||
);
|
||||
|
||||
let process = serde_json::json!({ "control": "cra-ai-36", "state": "not_code_checkable" });
|
||||
assert_eq!(state_sentence(&process, Lang::De), tx::PROCESS_GENERIC.de);
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,15 @@
|
||||
//! The help assistant answers in markdown, and semgrep rule messages are
|
||||
//! markdown (the finding description). Neither is ours, so nothing in it may
|
||||
//! reach the page as markup of its own: raw HTML is shown as text, and links
|
||||
//! keep only web and mail targets.
|
||||
//! keep only Breakpilot's own pages, relative paths and mail targets.
|
||||
//! Prüfwerk sends nobody to another site: a link anywhere else (an advisory
|
||||
//! database, a vendor page) is shown as its text, and an image from another
|
||||
//! site as its description.
|
||||
|
||||
use pulldown_cmark::{CowStr, Event, Options, Parser, Tag};
|
||||
use pulldown_cmark::{CowStr, Event, Options, Parser, Tag, TagEnd};
|
||||
|
||||
/// Link targets kept as they are; anything else (`javascript:`, `data:`, …)
|
||||
/// becomes an inert `#`.
|
||||
const SAFE_SCHEMES: &[&str] = &["https://", "http://", "mailto:"];
|
||||
/// The domain whose pages (and subdomains) a link may open.
|
||||
const OWN_DOMAIN: &str = "breakpilot.com";
|
||||
|
||||
/// Render `markdown` to HTML that is safe to insert into the page.
|
||||
///
|
||||
@@ -19,8 +21,9 @@ const SAFE_SCHEMES: &[&str] = &["https://", "http://", "mailto:"];
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// HTML with every raw HTML tag escaped and every link pointing at a web
|
||||
/// address, a mail address, a relative path, or `#`.
|
||||
/// HTML with every raw HTML tag escaped and every link pointing at a
|
||||
/// Breakpilot page, a mail address or a relative path; other links are left
|
||||
/// as their text.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@@ -29,47 +32,50 @@ const SAFE_SCHEMES: &[&str] = &["https://", "http://", "mailto:"];
|
||||
/// ```
|
||||
pub fn render_markdown(markdown: &str) -> String {
|
||||
let options = Options::ENABLE_TABLES | Options::ENABLE_STRIKETHROUGH;
|
||||
let events = Parser::new_ext(markdown, options).map(|event| match event {
|
||||
// Links and images do not nest, so one flag per kind says whether the
|
||||
// open one was dropped and its end tag must go too.
|
||||
let (mut link_dropped, mut image_dropped) = (false, false);
|
||||
let events = Parser::new_ext(markdown, options).filter_map(move |event| match event {
|
||||
// Shown as the text it is; `push_html` escapes text.
|
||||
Event::Html(html) | Event::InlineHtml(html) => Event::Text(html),
|
||||
Event::Start(Tag::Link {
|
||||
link_type,
|
||||
dest_url,
|
||||
title,
|
||||
id,
|
||||
}) => Event::Start(Tag::Link {
|
||||
link_type,
|
||||
dest_url: safe_url(dest_url),
|
||||
title,
|
||||
id,
|
||||
}),
|
||||
Event::Start(Tag::Image {
|
||||
link_type,
|
||||
dest_url,
|
||||
title,
|
||||
id,
|
||||
}) => Event::Start(Tag::Image {
|
||||
link_type,
|
||||
dest_url: safe_url(dest_url),
|
||||
title,
|
||||
id,
|
||||
}),
|
||||
other => other,
|
||||
Event::Html(html) | Event::InlineHtml(html) => Some(Event::Text(html)),
|
||||
Event::Start(Tag::Link { ref dest_url, .. }) => {
|
||||
link_dropped = !allowed(dest_url);
|
||||
(!link_dropped).then_some(event)
|
||||
}
|
||||
Event::End(TagEnd::Link) => (!std::mem::take(&mut link_dropped)).then_some(event),
|
||||
// An image's inner text is its description: a dropped image leaves it.
|
||||
Event::Start(Tag::Image { ref dest_url, .. }) => {
|
||||
image_dropped = !allowed(dest_url);
|
||||
(!image_dropped).then_some(event)
|
||||
}
|
||||
Event::End(TagEnd::Image) => (!std::mem::take(&mut image_dropped)).then_some(event),
|
||||
other => Some(other),
|
||||
});
|
||||
let mut html = String::with_capacity(markdown.len() * 3 / 2);
|
||||
pulldown_cmark::html::push_html(&mut html, events);
|
||||
html
|
||||
}
|
||||
|
||||
/// `url` when it is a web or mail address or a relative path, else `#`.
|
||||
fn safe_url(url: CowStr<'_>) -> CowStr<'_> {
|
||||
/// Whether a link to `url` may stay a link: a relative path, a mail
|
||||
/// address, or a web page on Breakpilot's own domain.
|
||||
fn allowed(url: &CowStr<'_>) -> bool {
|
||||
let lower = url.trim().to_ascii_lowercase();
|
||||
let relative = !lower.contains(':');
|
||||
if relative || SAFE_SCHEMES.iter().any(|scheme| lower.starts_with(scheme)) {
|
||||
url
|
||||
} else {
|
||||
CowStr::Borrowed("#")
|
||||
if lower.starts_with("mailto:") {
|
||||
return true;
|
||||
}
|
||||
let Some(rest) = lower
|
||||
.strip_prefix("https://")
|
||||
.or_else(|| lower.strip_prefix("http://"))
|
||||
else {
|
||||
// `//host/…` is another site, `javascript:` and the like are not pages.
|
||||
return !lower.contains(':') && !lower.starts_with("//");
|
||||
};
|
||||
// The host ends at the path, query or fragment; a `user@` before it and
|
||||
// a port after it are not part of it.
|
||||
let authority = rest.split(['/', '?', '#']).next().unwrap_or_default();
|
||||
let host = authority.rsplit('@').next().unwrap_or_default();
|
||||
let host = host.split(':').next().unwrap_or_default();
|
||||
host == OWN_DOMAIN || host.ends_with(&format!(".{OWN_DOMAIN}"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -99,11 +105,38 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn script_links_are_made_inert() {
|
||||
let html = render_markdown("[x](javascript:alert(1)) [y](https://example.com) [z](/guide)");
|
||||
fn only_breakpilot_pages_and_relative_paths_stay_links() {
|
||||
let html = render_markdown(
|
||||
"[x](javascript:alert(1)) [osv](https://osv.dev/vulnerability/CVE-1) \
|
||||
[docs](https://docs.breakpilot.com/pruefwerk/) [z](/guide) [m](mailto:a@b.example)",
|
||||
);
|
||||
assert!(!html.contains("javascript:"));
|
||||
assert!(html.contains("href=\"#\""));
|
||||
assert!(html.contains("href=\"https://example.com\""));
|
||||
assert!(!html.contains("osv.dev"));
|
||||
assert!(html.contains("osv"), "the text stays: {html}");
|
||||
assert!(html.contains("href=\"https://docs.breakpilot.com/pruefwerk/\""));
|
||||
assert!(html.contains("href=\"/guide\""));
|
||||
assert!(html.contains("href=\"mailto:a@b.example\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_look_alike_host_is_another_site() {
|
||||
for url in [
|
||||
"https://breakpilot.com.evil.example/x",
|
||||
"https://evilbreakpilot.com/x",
|
||||
"https://breakpilot.com@evil.example/x",
|
||||
"//evil.example/x",
|
||||
] {
|
||||
let html = render_markdown(&format!("[a]({url})"));
|
||||
assert!(!html.contains("href"), "{url}: {html}");
|
||||
}
|
||||
let html = render_markdown("[a](https://user@cloud.breakpilot.com:443/x)");
|
||||
assert!(html.contains("href"), "{html}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_image_from_another_site_leaves_its_description() {
|
||||
let html = render_markdown("");
|
||||
assert!(!html.contains("<img"));
|
||||
assert!(html.contains("diagram"));
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ use dioxus::prelude::*;
|
||||
use dioxus_free_icons::icons::bs_icons::*;
|
||||
use dioxus_free_icons::Icon;
|
||||
|
||||
use crate::components::copy_button::CopyButton;
|
||||
|
||||
use crate::infrastructure::notifications::{
|
||||
dismiss_notification, fetch_notification_count, fetch_notifications,
|
||||
mark_all_notifications_read,
|
||||
@@ -118,12 +120,10 @@ pub fn NotificationBell() -> Element {
|
||||
span { class: "notification-sev {sev_class}",
|
||||
"{notif.severity.to_uppercase()}"
|
||||
}
|
||||
// The id to copy, never a link off-site.
|
||||
span { class: "notification-cve-id",
|
||||
if let Some(ref url) = notif.url {
|
||||
a { href: "{url}", target: "_blank", "{notif.cve_id}" }
|
||||
} else {
|
||||
"{notif.cve_id}"
|
||||
}
|
||||
"{notif.cve_id}"
|
||||
CopyButton { value: notif.cve_id.clone(), small: true }
|
||||
}
|
||||
if let Some(score) = notif.cvss_score {
|
||||
span { class: "notification-cvss", "CVSS {score:.1}" }
|
||||
|
||||
@@ -15,6 +15,7 @@ use compliance_core::cve_matrix::CveFilter;
|
||||
use compliance_core::models::{CveAlert, SupplierVex, VexAssessment, VexJustification, VexStatus};
|
||||
use compliance_core::vex_docs::status_of;
|
||||
|
||||
use crate::components::copy_button::CopyButton;
|
||||
use crate::components::no_access::use_can_write;
|
||||
use crate::components::severity_badge::SeverityBadge;
|
||||
use crate::components::toast::{ToastType, Toasts};
|
||||
@@ -182,6 +183,36 @@ pub(crate) fn is_supplier_product(alert: &CveAlert) -> bool {
|
||||
/// agent stores it (`csaf_feed::SUPPLIER_PREFIX`).
|
||||
pub(crate) const SUPPLIER_PROVIDER_PREFIX: &str = "supplier:";
|
||||
|
||||
/// A vendor advisory that names a CVE alert: its id to copy, the vendor's
|
||||
/// remediation on hover, and a link to its page only where the provider's
|
||||
/// terms require one (Siemens ProductCERT). Nothing else leads off-site.
|
||||
#[component]
|
||||
pub(crate) fn AdvisoryLine(advisory: compliance_core::models::AdvisoryRef) -> Element {
|
||||
let lang = use_lang()();
|
||||
let hint = advisory
|
||||
.remediation
|
||||
.clone()
|
||||
.unwrap_or_else(|| advisory.title.clone());
|
||||
rsx! {
|
||||
div { class: "vex-advisory-line",
|
||||
span { class: "vex-advisory", title: "{hint}", "{advisory.id}" }
|
||||
CopyButton { value: advisory.id.clone(), small: true }
|
||||
if let Some(url) = advisory.required_backlink() {
|
||||
a {
|
||||
class: "vex-advisory-source",
|
||||
href: "{url}",
|
||||
target: "_blank",
|
||||
rel: "noopener noreferrer",
|
||||
{tx::SOURCE.get(lang)}
|
||||
}
|
||||
}
|
||||
if advisory.provider.starts_with(SUPPLIER_PROVIDER_PREFIX) {
|
||||
span { class: "vex-advisory-note", {tx::SUPPLIER_ADVISORY.get(lang)} }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
@@ -442,24 +473,13 @@ fn CveTable(
|
||||
rsx! {
|
||||
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.
|
||||
span { class: "vex-cve-id",
|
||||
code { "{alert.cve_id}" }
|
||||
CopyButton { value: alert.cve_id.clone(), small: true }
|
||||
}
|
||||
// The vendor advisories that name it (#515).
|
||||
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",
|
||||
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)} }
|
||||
}
|
||||
}
|
||||
AdvisoryLine { advisory: adv.clone() }
|
||||
}
|
||||
}
|
||||
td {
|
||||
|
||||
@@ -70,6 +70,21 @@ impl Text {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<compliance_core::cra_requirements::Words> for Text {
|
||||
fn from(words: compliance_core::cra_requirements::Words) -> Self {
|
||||
Self {
|
||||
de: words.de,
|
||||
en: words.en,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The name a customer reads for CRA requirement `id` (`cra-ai-8` is
|
||||
/// `Keine Standardpasswörter`); an id outside the 40 stays as it is.
|
||||
pub fn requirement_label(id: &str, lang: Lang) -> &str {
|
||||
compliance_core::cra_requirements::name(id).map_or(id, |words| Text::from(words).get(lang))
|
||||
}
|
||||
|
||||
/// The agent's refusal code in a server function's error message: the
|
||||
/// first word of `error` that is one of `codes`, as in
|
||||
/// `error running server function: label_taken (409) (details: None)`.
|
||||
|
||||
@@ -17,6 +17,14 @@ pub mod common {
|
||||
de: "Wird geladen …",
|
||||
en: "Loading...",
|
||||
};
|
||||
pub const COPY: Text = Text {
|
||||
de: "Kopieren",
|
||||
en: "Copy",
|
||||
};
|
||||
pub const COPIED: Text = Text {
|
||||
de: "Kopiert",
|
||||
en: "Copied",
|
||||
};
|
||||
pub const PREVIOUS: Text = Text {
|
||||
de: "Zurück",
|
||||
en: "Previous",
|
||||
@@ -3294,10 +3302,6 @@ pub mod sbom {
|
||||
de: "Keine",
|
||||
en: "None",
|
||||
};
|
||||
pub const VIEW_ADVISORY: Text = Text {
|
||||
de: "Hinweis ansehen →",
|
||||
en: "View advisory →",
|
||||
};
|
||||
pub const KEV_BADGE: Text = Text {
|
||||
de: "Aktiv ausgenutzt (KEV)",
|
||||
en: "Actively exploited (KEV)",
|
||||
@@ -3650,6 +3654,10 @@ pub mod vex {
|
||||
de: "Laut Lieferant",
|
||||
en: "Per the supplier",
|
||||
};
|
||||
pub const SOURCE: Text = Text {
|
||||
de: "Quelle",
|
||||
en: "Source",
|
||||
};
|
||||
pub const SUPPLIER_ADVISORY: Text = Text {
|
||||
de: "Hinweis des Zulieferers",
|
||||
en: "Supplier advisory",
|
||||
@@ -4145,26 +4153,26 @@ pub mod compliance {
|
||||
en: "Show CRA status",
|
||||
};
|
||||
pub const NOT_SATISFIED: Text = Text {
|
||||
de: "Befunde zugeordnet",
|
||||
en: "Findings mapped",
|
||||
de: "Offene Befunde",
|
||||
en: "Open findings",
|
||||
};
|
||||
pub const NO_VIOLATION: Text = Text {
|
||||
de: "Geprüft, keine Befunde",
|
||||
en: "Checked, no findings",
|
||||
de: "Nichts gefunden",
|
||||
en: "Nothing found",
|
||||
};
|
||||
pub const VIOLATED_COUNT: Text = Text {
|
||||
de: "mit Befunden",
|
||||
en: "with findings",
|
||||
};
|
||||
pub const NOT_ASSESSED: Text = Text {
|
||||
de: "Nicht geprüft",
|
||||
en: "Not checked",
|
||||
de: "Noch nicht geprüft",
|
||||
en: "Not checked yet",
|
||||
};
|
||||
/// A control checked on part of what it covers (a Yocto recipe
|
||||
/// inventory instead of the image's SBOM).
|
||||
pub const PARTIAL: Text = Text {
|
||||
de: "Teilweise geprüft",
|
||||
en: "Partly checked",
|
||||
de: "Nur teilweise geprüft",
|
||||
en: "Only partly checked",
|
||||
};
|
||||
pub const RECIPE_INVENTORY_ONLY: Text = Text {
|
||||
de: "Nur das Yocto-Rezeptinventar, nicht die SBOM des Images: geprüft sind die Rezepte im Layer-Baum, nicht was das Image enthält. Vollständig erst mit der SBOM aus dem Build.",
|
||||
@@ -4212,8 +4220,8 @@ pub mod compliance {
|
||||
en: "CVE lookup",
|
||||
};
|
||||
pub const NOT_CODE_CHECKABLE: Text = Text {
|
||||
de: "Nicht im Code prüfbar",
|
||||
en: "Not checkable in code",
|
||||
de: "Nachweis per Dokument",
|
||||
en: "Proven by a document",
|
||||
};
|
||||
pub const SHOW_REQUIREMENTS: Text = Text {
|
||||
de: "Anforderungen anzeigen",
|
||||
@@ -7188,22 +7196,22 @@ pub mod cra_tiles {
|
||||
de: "CRA Annex I",
|
||||
en: "CRA Annex I",
|
||||
};
|
||||
pub const BREADCRUMB: Text = Text {
|
||||
de: "Anforderung",
|
||||
en: "Requirement",
|
||||
pub const SELECTED: Text = Text {
|
||||
de: "Ausgewählte Anforderung",
|
||||
en: "Selected requirement",
|
||||
};
|
||||
pub const HINT: Text = Text {
|
||||
de: "Klick auf eine Kachel: die Anforderung mit den Befunden und Gründen dahinter.",
|
||||
en: "Click a tile: the requirement with the findings and reasons behind it.",
|
||||
};
|
||||
pub const BACK: Text = Text {
|
||||
de: "← Zurück zum Raster",
|
||||
en: "← Back to the grid",
|
||||
pub const PICK: Text = Text {
|
||||
de: "Klicken Sie auf eine Anforderung: Hier steht dann, was ihre Farbe bedeutet und worauf sie beruht.",
|
||||
en: "Click a requirement: this shows what its colour means and what it rests on.",
|
||||
};
|
||||
pub const UNKNOWN: Text = Text {
|
||||
de: "Diese Anforderung gibt es für dieses Prüfobjekt nicht.",
|
||||
en: "This target has no such requirement.",
|
||||
};
|
||||
pub const CLOSE: Text = Text {
|
||||
de: "Schließen",
|
||||
en: "Close",
|
||||
};
|
||||
pub const ALL_REQUIREMENTS: Text = Text {
|
||||
de: "Alle Anforderungen als Liste",
|
||||
en: "All requirements as a list",
|
||||
@@ -7212,14 +7220,81 @@ pub mod cra_tiles {
|
||||
de: "Der CRA-Stand konnte nicht geladen werden.",
|
||||
en: "The CRA status could not be loaded.",
|
||||
};
|
||||
pub const OTHER_AREA: Text = Text {
|
||||
de: "Weitere Anforderungen",
|
||||
en: "Other requirements",
|
||||
};
|
||||
pub const MEANINGS: Text = Text {
|
||||
de: "Was die Farben hier bedeuten",
|
||||
en: "What the colours mean here",
|
||||
};
|
||||
pub const NOW: Text = Text {
|
||||
de: ": so ist es jetzt",
|
||||
en: ": this is how it is now",
|
||||
};
|
||||
pub const RED: Text = Text {
|
||||
de: "Rot",
|
||||
en: "Red",
|
||||
};
|
||||
pub const ORANGE: Text = Text {
|
||||
de: "Orange",
|
||||
en: "Orange",
|
||||
};
|
||||
pub const GREEN: Text = Text {
|
||||
de: "Grün",
|
||||
en: "Green",
|
||||
};
|
||||
pub const PROOF_TITLE: Text = Text {
|
||||
de: "Nachweis per Dokument",
|
||||
en: "Proven by a document",
|
||||
};
|
||||
pub const AGAINST_GENERIC: Text = Text {
|
||||
de: "Sie sprechen gegen diese Anforderung.",
|
||||
en: "They count against this requirement.",
|
||||
};
|
||||
pub const CLEAR_GENERIC: Text = Text {
|
||||
de: "Der Scan fand nichts, was dagegen spricht.",
|
||||
en: "The scan found nothing against it.",
|
||||
};
|
||||
pub const OPEN_GENERIC: Text = Text {
|
||||
de: "Noch nicht geprüft: Es ist noch kein Scan gelaufen, oder keine Regel deckt dieses Prüfobjekt ab.",
|
||||
en: "Not checked yet: no scan has run, or no rule covers this target.",
|
||||
};
|
||||
pub const PROCESS_GENERIC: Text = Text {
|
||||
de: "Diese Anforderung betrifft Ihre Abläufe und Ihren Entwurf, nicht einzelne Codezeilen.",
|
||||
en: "This requirement is about your processes and design, not single lines of code.",
|
||||
};
|
||||
|
||||
/// The grid's heading: `CRA Annex I: 40 Anforderungen`.
|
||||
/// The map's heading: `CRA Annex I: 40 Anforderungen`.
|
||||
pub fn title(count: usize, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!("CRA Annex I: {count} Anforderungen"),
|
||||
Lang::En => format!("CRA Annex I: {count} requirements"),
|
||||
}
|
||||
}
|
||||
|
||||
/// How many open findings count against a requirement, as a sentence.
|
||||
pub fn against_count(count: usize, lang: Lang) -> String {
|
||||
match (lang, count) {
|
||||
(Lang::De, 1) => "Ein offener Befund spricht dagegen.".to_string(),
|
||||
(Lang::De, n) => format!("{n} offene Befunde sprechen dagegen."),
|
||||
(Lang::En, 1) => "One open finding counts against it.".to_string(),
|
||||
(Lang::En, n) => format!("{n} open findings count against it."),
|
||||
}
|
||||
}
|
||||
|
||||
/// The proof a requirement no scan decides asks for: `doc` is the
|
||||
/// document (`ein Rechtekonzept`).
|
||||
pub fn proof(doc: &str, lang: Lang) -> String {
|
||||
match lang {
|
||||
Lang::De => format!(
|
||||
"Ein Code-Scan kann diese Anforderung nicht entscheiden. Sie weisen sie mit einem Dokument nach: {doc}."
|
||||
),
|
||||
Lang::En => format!(
|
||||
"A code scan cannot decide this requirement. You prove it with a document: {doc}."
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The "Verlauf" of a target's views (#957): what each scan changed.
|
||||
|
||||
@@ -18,8 +18,8 @@ use crate::infrastructure::evidence::{fetch_compliance, CraCounts};
|
||||
/// them: violated first, requirements evidenced outside the code last.
|
||||
pub(crate) const STATES: [(&str, Text, &str); 5] = [
|
||||
("not_satisfied", tx::NOT_SATISFIED, "badge badge-critical"),
|
||||
("not_assessed", tx::NOT_ASSESSED, "badge badge-medium"),
|
||||
("partial", tx::PARTIAL, "badge badge-info"),
|
||||
("not_assessed", tx::NOT_ASSESSED, "badge badge-open"),
|
||||
("partial", tx::PARTIAL, "badge badge-medium"),
|
||||
(
|
||||
"no_violation_found",
|
||||
tx::NO_VIOLATION,
|
||||
@@ -163,11 +163,29 @@ pub fn CompliancePage(id: String) -> Element {
|
||||
}
|
||||
}
|
||||
|
||||
/// One requirement: its id and title, the catalog's rating, and what the
|
||||
/// state rests on (the findings against it, or why it was not assessed,
|
||||
/// unless `show_reason` is off because the group states it once).
|
||||
/// The name a customer reads for `control` (an entry of the compliance
|
||||
/// API's `controls`): the requirement's name, else the catalog's title for
|
||||
/// an id outside the 40, else the id.
|
||||
pub(crate) fn requirement_name(control: &serde_json::Value, lang: Lang) -> String {
|
||||
let id = control["control"].as_str().unwrap_or_default();
|
||||
match compliance_core::cra_requirements::name(id) {
|
||||
Some(words) => Text::from(words).get(lang).to_string(),
|
||||
None => control["title"].as_str().unwrap_or(id).to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// One requirement: its name, the catalog's rating, and what the state rests
|
||||
/// on (the findings against it, or why it was not assessed, unless
|
||||
/// `show_reason` is off because the group states it once). `headless` leaves
|
||||
/// the name line out where the requirement is already named above.
|
||||
#[component]
|
||||
pub(crate) fn ControlRow(control: serde_json::Value, lang: Lang, show_reason: bool) -> Element {
|
||||
pub(crate) fn ControlRow(
|
||||
control: serde_json::Value,
|
||||
lang: Lang,
|
||||
show_reason: bool,
|
||||
#[props(default)] headless: bool,
|
||||
) -> Element {
|
||||
let name = requirement_name(&control, lang);
|
||||
let findings = control["findings"].as_array().cloned().unwrap_or_default();
|
||||
// The control map's notes are engineering prose in English; in German
|
||||
// the group's hint says the same.
|
||||
@@ -186,8 +204,9 @@ pub(crate) fn ControlRow(control: serde_json::Value, lang: Lang, show_reason: bo
|
||||
rsx! {
|
||||
li { class: "cra-control",
|
||||
div { class: "cra-control-head",
|
||||
code { class: "cra-control-id", "{control[\"control\"].as_str().unwrap_or_default()}" }
|
||||
span { class: "cra-control-title", "{control[\"title\"].as_str().unwrap_or_default()}" }
|
||||
if !headless {
|
||||
span { class: "cra-control-title", "{name}" }
|
||||
}
|
||||
if let Some(label) = severity_label {
|
||||
span { class: "badge badge-{severity}", "{label}" }
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@ use dioxus_free_icons::Icon;
|
||||
|
||||
use crate::app::Route;
|
||||
use crate::components::code_snippet::CodeSnippet;
|
||||
use crate::components::cra_tiles::{cra_tone, StateMark};
|
||||
use crate::components::markdown::render_markdown;
|
||||
use crate::components::page_header::PageHeader;
|
||||
use crate::components::severity_badge::SeverityBadge;
|
||||
use crate::i18n::texts::{common, finding_breakdown, findings as tx, graph as graph_tx};
|
||||
use crate::i18n::{format_count, format_time, use_lang, Lang};
|
||||
use crate::i18n::{format_count, format_time, requirement_label, use_lang, Lang};
|
||||
use crate::infrastructure::evidence::{fetch_catalog_controls, CatalogControl};
|
||||
use crate::infrastructure::findings::{location, mask_secrets, wire_name};
|
||||
use crate::infrastructure::graph::fetch_impact;
|
||||
@@ -127,11 +128,12 @@ pub fn FindingDetailPage(id: String) -> Element {
|
||||
.as_ref()
|
||||
.and_then(|d| d["target_name"].as_str())
|
||||
.map(String::from);
|
||||
let control_title = |id: &str| -> Option<String> {
|
||||
// A requirement's state on the target, as the CRA map shows it.
|
||||
let control_state = |id: &str| -> Option<String> {
|
||||
status_data.as_ref()?["controls"]
|
||||
.as_array()?
|
||||
.iter()
|
||||
.find(|c| c["control"].as_str() == Some(id))?["title"]
|
||||
.find(|c| c["control"].as_str() == Some(id))?["state"]
|
||||
.as_str()
|
||||
.map(String::from)
|
||||
};
|
||||
@@ -143,8 +145,8 @@ pub fn FindingDetailPage(id: String) -> Element {
|
||||
let cra_topics: Vec<(String, Option<String>)> = cra_refs
|
||||
.into_iter()
|
||||
.map(|c| {
|
||||
let title = control_title(&c);
|
||||
(c, title)
|
||||
let state = control_state(&c);
|
||||
(c, state)
|
||||
})
|
||||
.collect();
|
||||
// Offer Breakpilot Git only once the agent said the target opens
|
||||
@@ -309,11 +311,22 @@ pub fn FindingDetailPage(id: String) -> Element {
|
||||
if !f.control_refs.is_empty() {
|
||||
span { style: "opacity: 0.7;", {tx::CRA_REFS.get(lang)} }
|
||||
ul { class: "finding-refs",
|
||||
for (c, title) in cra_topics {
|
||||
for (c, state) in cra_topics {
|
||||
li {
|
||||
span { class: "badge badge-info", "{c}" }
|
||||
if let Some(title) = title {
|
||||
span { " {title}" }
|
||||
Link {
|
||||
class: "ct-chip {cra_tone(state.as_deref())}",
|
||||
to: Route::TargetViewsPage {
|
||||
id: f.repo_id.clone(),
|
||||
view: crate::pages::target_views::RepoView::Cra.slug().to_string(),
|
||||
cve_severity: None,
|
||||
cve_vex: None,
|
||||
control: Some(c.clone()),
|
||||
scan: None,
|
||||
},
|
||||
if let Some(state) = state.clone() {
|
||||
StateMark { state }
|
||||
}
|
||||
span { class: "ct-chip-name", {requirement_label(&c, lang)} }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -675,7 +688,7 @@ fn tracker_note(
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `finding` - the finding shown on the page
|
||||
/// * `cra_topics` - its CRA control ids, each with its title when known
|
||||
/// * `cra_topics` - its CRA requirement ids, each with its state when known
|
||||
/// * `link` - the finding's page in Prüfwerk
|
||||
/// * `lang` - the UI language, for the labels
|
||||
///
|
||||
@@ -720,11 +733,8 @@ fn ticket_markdown(
|
||||
}
|
||||
if !cra_topics.is_empty() {
|
||||
md.push_str(&format!("\n### {}\n\n", tx::CRA_TOPICS.get(lang)));
|
||||
for (id, title) in cra_topics {
|
||||
match title {
|
||||
Some(title) => md.push_str(&format!("- `{id}` {title}\n")),
|
||||
None => md.push_str(&format!("- `{id}`\n")),
|
||||
}
|
||||
for (id, _) in cra_topics {
|
||||
md.push_str(&format!("- {}\n", requirement_label(id, lang)));
|
||||
}
|
||||
}
|
||||
md.push_str(&format!(
|
||||
@@ -855,10 +865,7 @@ mod tests {
|
||||
#[test]
|
||||
fn the_ticket_text_holds_the_finding_and_a_link_back() {
|
||||
let topics = vec![
|
||||
(
|
||||
"cra-ai-2c".to_string(),
|
||||
Some("Schutz vor unbefugtem Zugriff".to_string()),
|
||||
),
|
||||
("cra-ai-8".to_string(), Some("not_satisfied".to_string())),
|
||||
("cra-ai-2f".to_string(), None),
|
||||
];
|
||||
let md = ticket_markdown(
|
||||
@@ -876,8 +883,8 @@ mod tests {
|
||||
\n### Beschreibung\n\nDie Abfrage setzt Benutzereingaben direkt ein.\n\
|
||||
\n### Einschätzung\n\nErreichbar über das Login-Formular.\n\
|
||||
\n### CRA-Themen\n\n\
|
||||
- `cra-ai-2c` Schutz vor unbefugtem Zugriff\n\
|
||||
- `cra-ai-2f`\n\
|
||||
- Keine Standardpasswörter\n\
|
||||
- cra-ai-2f\n\
|
||||
\n[Im Prüfwerk öffnen](https://pruefwerk.example/findings/abc)\n"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use crate::components::toast::{ToastType, Toasts};
|
||||
use crate::i18n::texts::{
|
||||
common, finding_breakdown as breakdown_tx, finding_groups as gtx, findings as tx,
|
||||
};
|
||||
use crate::i18n::use_lang;
|
||||
use crate::i18n::{requirement_label, use_lang};
|
||||
use crate::infrastructure::findings::{has_control_refs, location, wire_name};
|
||||
use compliance_core::finding_breakdown::OPEN_STATUS_FILTER;
|
||||
|
||||
@@ -436,9 +436,9 @@ pub fn FindingsPage(
|
||||
if show_controls {
|
||||
td {
|
||||
{
|
||||
// CRA Annex I refs by name; master controls
|
||||
// (`mc-…`) only as a count, their detail is on
|
||||
// the finding's page.
|
||||
// CRA Annex I requirements by name; master
|
||||
// controls (`mc-…`) only as a count, their
|
||||
// detail is on the finding's page.
|
||||
let (cra, other): (Vec<&String>, Vec<&String>) = finding
|
||||
.control_refs
|
||||
.iter()
|
||||
@@ -446,7 +446,9 @@ pub fn FindingsPage(
|
||||
rsx! {
|
||||
div { class: "finding-controls",
|
||||
for c in cra {
|
||||
span { class: "badge badge-info", title: tx::CONTROLS_HINT.get(lang), "{c}" }
|
||||
span { class: "finding-control", title: tx::CONTROLS_HINT.get(lang),
|
||||
{requirement_label(c, lang)}
|
||||
}
|
||||
}
|
||||
if !other.is_empty() {
|
||||
span { class: "finding-controls-more",
|
||||
|
||||
@@ -12,10 +12,11 @@ use compliance_core::scan_changes::ComponentRowKind;
|
||||
use compliance_core::vex_docs::status_of;
|
||||
|
||||
use crate::app::Route;
|
||||
use crate::components::copy_button::CopyButton;
|
||||
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,
|
||||
is_supplier_product, status_class, status_text, supplier_gist, AdvisoryLine,
|
||||
};
|
||||
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};
|
||||
@@ -477,21 +478,12 @@ fn MachineCveGroup(
|
||||
rsx! {
|
||||
tr { key: "{alert.repo_id}-{alert.cve_id}",
|
||||
td {
|
||||
code { "{alert.cve_id}" }
|
||||
span { class: "vex-cve-id",
|
||||
code { "{alert.cve_id}" }
|
||||
CopyButton { value: alert.cve_id.clone(), small: true }
|
||||
}
|
||||
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)} }
|
||||
}
|
||||
}
|
||||
AdvisoryLine { advisory: adv.clone() }
|
||||
}
|
||||
}
|
||||
td {
|
||||
|
||||
@@ -4,6 +4,7 @@ use dioxus::prelude::*;
|
||||
|
||||
use crate::app::Route;
|
||||
use crate::components::component_overview::ComponentOverview;
|
||||
use crate::components::copy_button::CopyButton;
|
||||
use crate::components::license_editor::{category_class, confirmed_title, LicenseEditor};
|
||||
use crate::components::license_review::{
|
||||
action_class, reasons_text, review_title, LicenseCheckPanel,
|
||||
@@ -545,7 +546,9 @@ pub fn SbomPage(target: String, #[props(default)] ecosystem: String) -> Element
|
||||
for vuln in &entry.known_vulnerabilities {
|
||||
div { class: "sbom-vuln-card",
|
||||
div { class: "sbom-vuln-card-header",
|
||||
// The id to copy, never a link off-site.
|
||||
span { class: "sbom-vuln-id", "{vuln.id}" }
|
||||
CopyButton { value: vuln.id.clone(), small: true }
|
||||
span { class: "sbom-vuln-source", "{vuln.source}" }
|
||||
if let Some(sev) = &vuln.severity {
|
||||
span {
|
||||
@@ -573,14 +576,6 @@ pub fn SbomPage(target: String, #[props(default)] ecosystem: String) -> Element
|
||||
"{tx::SSVC_EXPLOITATION.get(lang)}: {ssvc}"
|
||||
}
|
||||
}
|
||||
if let Some(url) = &vuln.url {
|
||||
a {
|
||||
href: "{url}",
|
||||
target: "_blank",
|
||||
class: "sbom-vuln-link",
|
||||
{tx::VIEW_ADVISORY.get(lang)}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if entry.known_vulnerabilities.iter().any(|v| v.exploitation.as_ref().is_some_and(|e| e.epss.is_some())) {
|
||||
|
||||
@@ -109,9 +109,10 @@ pub struct ListCvesParams {
|
||||
}
|
||||
|
||||
/// `list_cves`: the CVE alerts of a target's dependencies and firmware
|
||||
/// libraries, highest CVSS first.
|
||||
/// libraries, highest CVSS first, without a `fixed` a scan inferred from a
|
||||
/// CVE no longer being found (#994).
|
||||
pub async fn list_cves(db: &Database, params: ListCvesParams) -> Result<CallToolResult, McpError> {
|
||||
let alerts = collect(
|
||||
let mut alerts: Vec<compliance_core::models::CveAlert> = collect(
|
||||
db.cve_alerts()
|
||||
.find(doc! { "repo_id": ¶ms.target_id })
|
||||
.sort(doc! { "cvss_score": -1 })
|
||||
@@ -119,6 +120,9 @@ pub async fn list_cves(db: &Database, params: ListCvesParams) -> Result<CallTool
|
||||
.map_err(db_error)?,
|
||||
)
|
||||
.await?;
|
||||
alerts
|
||||
.iter_mut()
|
||||
.for_each(compliance_core::models::CveAlert::drop_inferred_fix);
|
||||
json_result(&alerts)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ A scan opens issues only for the findings it finds new, so a finding whose issue
|
||||
|
||||
### CVE issues (managed repositories)
|
||||
|
||||
For a repository from a managed git source, known vulnerabilities in its dependencies become issues too: one per package and CVE, labelled `cve`. A critical or high CVE opens one, and so does any CVE in CISA's Known Exploited Vulnerabilities catalog (rated at least high). A CVE whose EPSS percentile reaches `CVE_ISSUE_EPSS_PERCENTILE` (default `0.95`) is rated one step higher, so a medium one opens an issue as high. The issue names the KEV entry, the EPSS score with its attribution, and CISA's SSVC exploitation where known. When a complete scan no longer finds the CVE, the issue is closed; when it comes back, it is reopened. A CVE with the VEX status `not_affected` or `fixed` gets no new issue. Its issue that is already open is closed only with `ISSUE_AUTOCLOSE=on`: with a comment naming the status and the justification, at most 20 per target and scan (the rest follow in the next scans). `ISSUE_AUTOCLOSE=dry_run` only logs, per target, how many issues it would close per VEX status, and changes nothing; the default is `off`. When the statement is withdrawn, a closed issue is reopened.
|
||||
For a repository from a managed git source, known vulnerabilities in its dependencies become issues too: one per package and CVE, labelled `cve`. A critical or high CVE opens one, and so does any CVE in CISA's Known Exploited Vulnerabilities catalog (rated at least high). A CVE whose EPSS percentile reaches `CVE_ISSUE_EPSS_PERCENTILE` (default `0.95`) is rated one step higher, so a medium one opens an issue as high. The issue names the KEV entry, the EPSS score with its attribution, and CISA's SSVC exploitation where known. When a complete scan no longer finds the CVE, the issue stays open and is told so once: a CVE can disappear without a fix, so a person checks and closes it. A closed issue whose CVE comes back is reopened. A CVE with the VEX status `not_affected` or `fixed` gets no new issue. Its issue that is already open is closed only with `ISSUE_AUTOCLOSE=on`: with a comment naming the status and the justification, at most 20 per target and scan (the rest follow in the next scans). `ISSUE_AUTOCLOSE=dry_run` only logs, per target, how many issues it would close per VEX status, and changes nothing; the default is `off`. When the statement is withdrawn, a closed issue is reopened.
|
||||
|
||||
### Closing an issue in Gitea
|
||||
|
||||
|
||||
@@ -22,9 +22,10 @@ of an organisation in that instance automatically:
|
||||
- **Known vulnerabilities as issues.** A critical or high CVE in a dependency
|
||||
becomes one issue per package and CVE (`[CVE] okhttp@3.12.0: CVE-2021-0341`),
|
||||
labelled like the findings plus `cve`, with the fixed version where the
|
||||
advisory names one. When a complete scan no longer finds it (the dependency
|
||||
was updated or removed), the issue is closed with a comment; if it comes
|
||||
back, it is reopened.
|
||||
advisory names one. When a complete scan no longer finds it, the issue stays
|
||||
open and gets one comment saying so: a CVE can disappear without a fix, so
|
||||
you check and close it yourself (in Prüfwerk, set the VEX status "fixed"
|
||||
with a reason). If it comes back and goes again, it is told again.
|
||||
- **The issue follows the finding.** When the finding is closed in Prüfwerk —
|
||||
the scan no longer finds it, or someone marks it resolved, a false alarm or
|
||||
ignored — Prüfwerk comments on the issue why and closes it. An accepted risk
|
||||
|
||||
@@ -24,9 +24,11 @@ Repository-Organisation dieser Instanz automatisch prüfen:
|
||||
Abhängigkeit wird ein Issue je Paket und CVE
|
||||
(`[CVE] okhttp@3.12.0: CVE-2021-0341`), mit denselben Labels wie die Befunde
|
||||
plus `cve` und der behebenden Version, wenn die Meldung eine nennt. Findet
|
||||
eine vollständige Prüfung sie nicht mehr (Abhängigkeit aktualisiert oder
|
||||
entfernt), wird das Issue mit Kommentar geschlossen; taucht sie wieder auf,
|
||||
wird es wieder geöffnet.
|
||||
eine vollständige Prüfung sie nicht mehr, bleibt das Issue offen und erhält
|
||||
einmal einen Kommentar dazu: Eine CVE kann auch ohne Behebung verschwinden,
|
||||
deshalb prüfen und schließen Sie es selbst (im Prüfwerk mit dem VEX-Status
|
||||
„Behoben“ und Begründung). Taucht sie wieder auf und verschwindet erneut,
|
||||
kommt der Hinweis noch einmal.
|
||||
- **Das Issue folgt dem Befund.** Wird der Befund im Prüfwerk geschlossen –
|
||||
die Prüfung findet ihn nicht mehr, oder jemand setzt ihn auf behoben,
|
||||
Fehlalarm oder ignoriert –, kommentiert Prüfwerk im Issue den Grund und
|
||||
|
||||
+6
-5
@@ -684,11 +684,12 @@ Justifications for `not_affected` (OpenVEX): `component_not_present`,
|
||||
`inline_mitigations_already_exist`. A statement without what its status
|
||||
requires is refused.
|
||||
|
||||
A scan keeps the status current: when a complete CVE check no longer finds an
|
||||
alert (the component was removed or updated past the fix), it is marked
|
||||
resolved, and one nobody assessed, or assessed as affected, becomes `fixed`.
|
||||
A `not_affected` or `fixed` someone stated is never changed by a scan. If the
|
||||
vulnerability comes back, the scan's `fixed` is withdrawn. A Yocto recipe's
|
||||
When a complete CVE check no longer finds an alert, it is marked resolved and
|
||||
keeps its status: a scan never states `fixed` for it, since a vulnerability
|
||||
can disappear without a fix. An alert nobody assessed stays
|
||||
`under_investigation` in the exports until someone states its status. A
|
||||
`fixed` scans stated that way before is not read as a statement. A statement
|
||||
someone made is never changed by a scan. A Yocto recipe's
|
||||
`CVE_STATUS` and `CVE:` patches are stated by the scan too (see
|
||||
[Embedded Linux / Yocto](/guide/yocto#recipe-inventory)), likewise never over a
|
||||
person's statement.
|
||||
|
||||
+11
-8
@@ -55,10 +55,12 @@ Read-only roles see the statements but cannot assess.
|
||||
|
||||
## What a scan changes
|
||||
|
||||
When a complete scan no longer finds a vulnerability (the component was
|
||||
removed or updated), it is marked fixed and "Stated by" shows **Scan**. A
|
||||
"Not affected" or "Fixed" stated by a person is never changed by a scan. If
|
||||
the vulnerability comes back, the scan withdraws its "Fixed".
|
||||
When a complete scan no longer finds a vulnerability, it is no longer open,
|
||||
and its assessment stays as it is. A scan never states "Fixed" for it: a
|
||||
vulnerability can disappear without a fix, for example through other scan
|
||||
data, an incomplete inventory or a changed identification. Only a person
|
||||
states "Fixed". A "Fixed" a scan stated that way before is not read as a
|
||||
statement. A statement made by a person is never changed by a scan.
|
||||
|
||||
A vulnerability that is "Not affected" or "Fixed" (stated by a person, by the
|
||||
scan or in an imported VEX document) raises no notification and gets no issue
|
||||
@@ -142,10 +144,11 @@ CVE) or it affects several components. The draft
|
||||
yourself, through the CSIRT of your main establishment.
|
||||
|
||||
Through the API you can give the time the deadlines run from (`aware_at`);
|
||||
without it, the first scan that found the exploitation counts. For a fixed
|
||||
vulnerability the draft carries the date of the fix (field v22) and the final
|
||||
report's deadline. A vulnerability assessed "Not affected", or fixed before
|
||||
any scan found it exploited, gets no draft. Actively
|
||||
without it, the first scan that found the exploitation counts. For a vulnerability
|
||||
assessed "Fixed" the draft carries the date of that statement (field v22) and
|
||||
the final report's deadline. One a scan only no longer finds leaves both open
|
||||
until someone states "Fixed". A vulnerability assessed "Not affected", or
|
||||
fixed or no longer found before any scan found it exploited, gets no draft. Actively
|
||||
exploited vulnerabilities are also in the evidence pack as
|
||||
`enisa-drafts.json`. When ENISA changes the glossary we update the fields;
|
||||
the version in a draft shows which one it follows.
|
||||
+12
-9
@@ -58,11 +58,13 @@ Rollen mit Lesezugriff sehen die Aussagen, können aber nicht bewerten.
|
||||
|
||||
## Was die Prüfung ändert
|
||||
|
||||
Findet eine vollständige Prüfung eine Schwachstelle nicht mehr (Komponente
|
||||
entfernt oder aktualisiert), wird sie als behoben markiert; „Aussage von“
|
||||
zeigt dann **Prüfung**. Eine Aussage „Nicht betroffen“ oder „Behoben“, die
|
||||
eine Person gemacht hat, ändert die Prüfung nie. Taucht die Schwachstelle
|
||||
wieder auf, nimmt die Prüfung ihr „Behoben“ zurück.
|
||||
Findet eine vollständige Prüfung eine Schwachstelle nicht mehr, gilt sie
|
||||
nicht mehr als offen; ihre Bewertung bleibt, wie sie ist. Die Prüfung setzt
|
||||
dafür nie „Behoben“: Eine Schwachstelle kann auch ohne Behebung
|
||||
verschwinden, etwa durch andere Scandaten, eine unvollständige Erfassung oder
|
||||
eine geänderte Zuordnung. „Behoben“ sagt nur eine Person. Ein „Behoben“, das
|
||||
die Prüfung früher so gesetzt hat, gilt nicht als Aussage. Eine Aussage, die
|
||||
eine Person gemacht hat, ändert die Prüfung nie.
|
||||
|
||||
Eine Schwachstelle mit „Nicht betroffen“ oder „Behoben“ (von einer Person,
|
||||
der Prüfung oder aus einem importierten VEX-Dokument) löst keine
|
||||
@@ -151,10 +153,11 @@ die CVE dazu) oder sie mehrere Komponenten betrifft. Der Entwurf
|
||||
|
||||
Den Zeitpunkt, ab dem die Fristen laufen, können Sie über die API angeben
|
||||
(`aware_at`); ohne ihn gilt die erste Prüfung, die die Ausnutzung fand. Ist
|
||||
eine behobene Schwachstelle bekannt, trägt der Entwurf das Datum der Behebung
|
||||
(Feld v22) und die Frist des Abschlussberichts. Ist sie als „Nicht
|
||||
betroffen“ bewertet, oder wurde sie behoben, bevor eine Prüfung ihre
|
||||
Ausnutzung fand, gibt es keinen Entwurf. Aktiv ausgenutzte Schwachstellen stehen als
|
||||
eine Schwachstelle als „Behoben“ bewertet, trägt der Entwurf das Datum dieser
|
||||
Aussage (Feld v22) und die Frist des Abschlussberichts. Findet die Prüfung sie
|
||||
nur nicht mehr, bleibt beides offen, bis jemand „Behoben“ sagt. Ist sie als
|
||||
„Nicht betroffen“ bewertet, oder wurde sie behoben oder nicht mehr gefunden,
|
||||
bevor eine Prüfung ihre Ausnutzung fand, gibt es keinen Entwurf. Aktiv ausgenutzte Schwachstellen stehen als
|
||||
`enisa-drafts.json` auch im Nachweispaket. Ändert ENISA das Glossar,
|
||||
passen wir die Felder an; die Version im Entwurf zeigt, nach welchem er
|
||||
erstellt wurde.
|
||||
@@ -0,0 +1,53 @@
|
||||
// #994: count, and only on request remove, the VEX `fixed` statements that
|
||||
// scans inferred from a CVE no longer being found (before the fix, Weg A).
|
||||
//
|
||||
// Since the fix, every reader ignores them (`CveAlert::statement`), so the
|
||||
// stored statements no longer reach an export, the dashboard or a tracker.
|
||||
// This script removes them from the data too; whether and when it runs is the
|
||||
// owner's decision on #994. The alerts keep `resolved_at`: that the scan no
|
||||
// longer finds the CVE stays recorded, as an observation.
|
||||
//
|
||||
// A statement counts when a scan made it (`by_scan`), it says `fixed`, and it
|
||||
// gives no reason (`impact_statement`). A scan's statement from the target's
|
||||
// own data (a Yocto recipe's patch) always gives one, so it is never matched.
|
||||
//
|
||||
// It prints counts only, never a database, target or CVE. Dry run unless
|
||||
// `apply` is true:
|
||||
//
|
||||
// mongosh "$MONGODB_URI" --quiet \
|
||||
// --eval 'var prefix = "<DB prefix>", apply = false' \
|
||||
// scripts/vex-994-cleanup.js
|
||||
|
||||
if (typeof prefix !== "string" || prefix === "") {
|
||||
throw new Error("set prefix, the agent's database prefix");
|
||||
}
|
||||
const write = typeof apply !== "undefined" && apply === true;
|
||||
|
||||
const inferred = {
|
||||
"vex.by_scan": true,
|
||||
"vex.status": "fixed",
|
||||
"vex.impact_statement": null,
|
||||
};
|
||||
|
||||
let databases = 0;
|
||||
let matched = 0;
|
||||
let removed = 0;
|
||||
for (const { name } of db.adminCommand({ listDatabases: 1, nameOnly: true }).databases) {
|
||||
if (!name.startsWith(prefix + "_")) {
|
||||
continue;
|
||||
}
|
||||
const alerts = db.getSiblingDB(name).getCollection("cve_alerts");
|
||||
const count = alerts.countDocuments(inferred);
|
||||
if (count === 0) {
|
||||
continue;
|
||||
}
|
||||
databases += 1;
|
||||
matched += count;
|
||||
if (write) {
|
||||
removed += alerts.updateMany(inferred, { $unset: { vex: "" } }).modifiedCount;
|
||||
}
|
||||
}
|
||||
|
||||
print(
|
||||
JSON.stringify({ mode: write ? "apply" : "dry-run", databases, statements: matched, removed }),
|
||||
);
|
||||
Reference in new issue
Block a user