support/scripts/cve-check: don't fail with unknown CVE

The NVD database has CVE entries that are not present but may be
referenced in other security trackers.

For instance the CVE-2024-12455 is documented in the Debian security
tracker [1]. However, the NVD page is empty [2] and this entry is not
present in the NVD database mirror.

The following command would make the script fail:

```
echo '{
  "vulnerabilities": [
    {
      "id": "CVE-2024-12455"
    }
  ]
}' | support/scripts/cve-check --enrich-only
```

No CVEs present in Buildroot ignored CVEs are affected. But when
enriching an SBOM with legitimate CVE not present on NVD, the script
will fail.

This patch change the behavior to just log to stderr unknown CVEs
instead of making the script fail.

[1] https://security-tracker.debian.org/tracker/CVE-2024-12455
[2] https://nvd.nist.gov/vuln/detail/CVE-2024-12455

Signed-off-by: Thomas Perale <thomas.perale@mind.be>
[Peter: Tweak warning message]
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
(cherry picked from commit fa7fac0985)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
This commit is contained in:
Thomas Perale
2025-12-07 10:28:20 +01:00
parent 03bc288c6b
commit 10fee753bb

View File

@@ -271,10 +271,13 @@ def enrich_vulnerabilities(nvd_path: Path, sbom):
if vuln_id is None or not vuln_id.upper().startswith("CVE-"):
continue
cve = cvecheck.CVE.read_nvd_entry(nvd_path, vuln["id"])
cve = cvecheck.CVE.read_nvd_entry(nvd_path, vuln_id)
if cve is None:
print(f"Warning: '{vuln_id}' doesn't exist in NVD database.", file=sys.stderr)
continue
vulnerability = nvd_cve_to_cdx_vulnerability(cve.nvd_cve)
vuln_append_or_update_affects_if_exists(vulnerabilities, vulnerability)