fix(vex): an issue whose CVE is gone stays open, told so once (#994)
CI / Detect Changes (pull_request) Skipped
CI / Check (push) Skipped
CI / Agent integration (pull_request) Successful in 5m21s
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) Failing after 10m40s
CI / Detect Changes (pull_request) Skipped
CI / Check (push) Skipped
CI / Agent integration (pull_request) Successful in 5m21s
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) Failing after 10m40s
A complete scan that no longer finds a CVE closed its tracker issue. A CVE can disappear without a fix, so the issue now stays open and gets one comment saying the scan no longer finds it and that a person checks and closes it (in Prüfwerk with the VEX status "Behoben" and a reason). TrackerIssue::gone_noted_at keeps it to one comment while the CVE stays gone; when the CVE is found again it is cleared, so a later disappearance is told again. Docs (managed git, issues) say the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
This commit is contained in:
1 parent
63eebef021
commit
fb28d0742b
6 files changed
+115
-35
No files matched your search
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -505,6 +526,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 +761,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!(
|
||||
@@ -783,30 +825,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.
|
||||
@@ -1025,14 +1087,18 @@ mod tests {
|
||||
}
|
||||
);
|
||||
|
||||
// Gone: closed for being gone, never with a VEX status.
|
||||
// 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(),
|
||||
closed(1)
|
||||
CveIssueCounts {
|
||||
noted_gone: 1,
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
{
|
||||
let calls = calls.lock().unwrap();
|
||||
assert!(calls.iter().all(|c| !c.contains("VEX")), "{calls:?}");
|
||||
assert!(calls.iter().all(|c| !c.starts_with("state ")), "{calls:?}");
|
||||
assert!(
|
||||
calls.iter().any(|c| c.contains("no longer finds")),
|
||||
"{calls:?}"
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user