test(nightly): the report shows each target's CVE matches (#377)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 8m44s
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 8m44s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
1 parent
e399cea0b6
commit
6bca8598c9
1 file changed
+35
-8
@@ -389,6 +389,20 @@ impl Snapshot {
|
||||
}
|
||||
}
|
||||
|
||||
/// A target's heading and one-line summary in the report: what it found,
|
||||
/// including the CVEs it matched (NVD answers change daily, so the baseline
|
||||
/// holds a lower bound; the count shows what a run actually saw).
|
||||
fn summary(key: &str, pass: bool, got: &Collected) -> String {
|
||||
format!(
|
||||
"## {key} ({})\n\n{} findings, {} SBOM components, {} CVEs, scan {}\n\n",
|
||||
if pass { "pass" } else { "FAIL" },
|
||||
got.observed.findings,
|
||||
got.observed.sbom_components,
|
||||
got.snapshot.cves.len(),
|
||||
got.snapshot.scan_status,
|
||||
)
|
||||
}
|
||||
|
||||
/// Everything one finished target produced.
|
||||
struct Collected {
|
||||
snapshot: Snapshot,
|
||||
@@ -674,14 +688,7 @@ async fn nightly_scan_regression() {
|
||||
)),
|
||||
}
|
||||
}
|
||||
report.push_str(&format!(
|
||||
"## {} ({})\n\n{} findings, {} SBOM components, scan {}\n\n",
|
||||
t.key,
|
||||
if problems.is_empty() { "pass" } else { "FAIL" },
|
||||
got.observed.findings,
|
||||
got.observed.sbom_components,
|
||||
got.snapshot.scan_status,
|
||||
));
|
||||
report.push_str(&summary(&t.key, problems.is_empty(), &got));
|
||||
for p in &problems {
|
||||
report.push_str(&format!("- {p}\n"));
|
||||
}
|
||||
@@ -749,6 +756,26 @@ mod unit {
|
||||
assert!(!diff.iter().any(|d| d.contains("CVE")), "{diff:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_summary_shows_the_cves_a_run_matched() {
|
||||
let got = Collected {
|
||||
snapshot: Snapshot {
|
||||
scan_status: "completed".into(),
|
||||
cves: set(&["CVE-2020-22283", "CVE-2020-22284"]),
|
||||
..Default::default()
|
||||
},
|
||||
observed: Observed {
|
||||
findings: 3,
|
||||
sbom_components: 5,
|
||||
..Default::default()
|
||||
},
|
||||
};
|
||||
assert_eq!(
|
||||
summary("fw-embedded-libs", true, &got),
|
||||
"## fw-embedded-libs (pass)\n\n3 findings, 5 SBOM components, 2 CVEs, scan completed\n\n"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn our_semgrep_rules_are_recognised_behind_a_config_prefix() {
|
||||
assert_eq!(
|
||||
|
||||
Reference in new issue
Block a user