This commit was merged in pull request #396.
This commit is contained in:
1 parent
a3cfaf422f
commit
ce93cc08d5
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