A complete scan that no longer finds a CVE used to state VEX `fixed` (Weg A), and the exports read `resolved_at` without a statement as `fixed` (Weg B). A CVE can disappear without a fix, so neither holds. - resolve_gone only sets resolved_at; it states nothing. - CveAlert::statement() ignores the `fixed` scans inferred that way (by_scan, fixed, no reason given); a Yocto recipe's statement gives its reason and still counts. status_of, is_resolved_by_vex, the exports, the CVE groups and the ENISA drafts all read through it. - status_of: no statement means under_investigation, gone or not. - ENISA: the final report is dated only by a person's `fixed`; an exploited CVE that is merely gone reads "no longer found", not fixed. - The CVE list (API and MCP) leaves the inferred statements out, so the dashboard no longer shows them. - scripts/vex-994-cleanup.js counts the stored ones and removes them only with apply=true; dry run by default, counts only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
// #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 }),
|
|
);
|