fix(cve): NVD lookups retry, cache, and record what they missed (#387) #390

Merged
sharang merged 1 commits from fix/nvd-lookups into main 2026-09-25 10:52:39 +00:00
Owner

Closes #387.

When NVD was rate-limited or unreachable, CVE matching failed quietly: the scan completed and simply listed fewer CVEs. Two manual nightly runs on 2026-09-25 lost 4 and then 220 CVEs, a different set each time. A customer scan during an NVD limit would have looked complete.

Changes

  • NVD client (pipeline/nvd_cpe.rs):
    • A rate-limited or failed request (403, 429, 5xx, network) is retried after 6, 12 and 24 s. NVD asks for about 6 s between requests.
    • Each product's answer is cached in the agent for 6 h, so repeated scans don't spend the rate budget again: a nightly corpus, or several targets with the same FreeRTOS or CODESYS runtime.
    • A 404 is not retried.
  • The CVE scanner reports what it could not check. scan_embedded and scan_codesys return a CveLookup with the alerts and the components whose lookup failed (for example "lwIP 2.1.2").
  • The run records the gap. Each of these becomes the skipped stage cve_lookup with its reason: an OSV failure or timeout, NVD components not checked, an NVD timeout. The timeout for the NVD lookups is 300 s, up from 120, to leave room for the retries.
  • CRA status. A control counts as "no violation found" only if none of the tools that apply to it failed in the last scan.
    • Skipped stages map to tools: cve_lookup to osv, sast to semgrep, sast_c_cpp to cppcheck.
    • A failed CVE lookup therefore makes cra-ai-22 and cra-ai-33 "not assessed" (tool_failed) instead of clean.
    • A failed semgrep run now does the same for the controls it checks.
  • Dashboard. The stage "CVE-Abgleich unvollständig" and the reason "Bei der letzten Prüfung nicht vollständig gelaufen: …" are shown in DE/EN.

Nightly

The nightly compares skipped stages exactly. An NVD outage now shows as cve_lookup in the report, not as a list of missing CVEs.

Checked

  • cargo fmt --all --check.
  • clippy with the CI flags for compliance-agent and the dashboard (server, web).
  • Tests: agent 435, dashboard 49 / 33. They include:
    • a local NVD stand-in: rate-limited twice then answered, the second ask served from the cache, a lasting 429 is an error after four tries, a 404 is not retried;
    • a failed CVE lookup makes cra-ai-22 "not assessed" while memory safety is unaffected;
    • the DE reason text.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

Closes #387. When NVD was rate-limited or unreachable, CVE matching failed quietly: the scan completed and simply listed fewer CVEs. Two manual nightly runs on 2026-09-25 lost 4 and then 220 CVEs, a different set each time. A customer scan during an NVD limit would have looked complete. ## Changes - **NVD client** (`pipeline/nvd_cpe.rs`): - A rate-limited or failed request (403, 429, 5xx, network) is retried after 6, 12 and 24 s. NVD asks for about 6 s between requests. - Each product's answer is cached in the agent for 6 h, so repeated scans don't spend the rate budget again: a nightly corpus, or several targets with the same FreeRTOS or CODESYS runtime. - A 404 is not retried. - **The CVE scanner reports what it could not check.** `scan_embedded` and `scan_codesys` return a `CveLookup` with the alerts and the components whose lookup failed (for example "lwIP 2.1.2"). - **The run records the gap.** Each of these becomes the skipped stage `cve_lookup` with its reason: an OSV failure or timeout, NVD components not checked, an NVD timeout. The timeout for the NVD lookups is 300 s, up from 120, to leave room for the retries. - **CRA status.** A control counts as "no violation found" only if none of the tools that apply to it failed in the last scan. - Skipped stages map to tools: `cve_lookup` to osv, `sast` to semgrep, `sast_c_cpp` to cppcheck. - A failed CVE lookup therefore makes cra-ai-22 and cra-ai-33 "not assessed" (`tool_failed`) instead of clean. - A failed semgrep run now does the same for the controls it checks. - **Dashboard.** The stage "CVE-Abgleich unvollständig" and the reason "Bei der letzten Prüfung nicht vollständig gelaufen: …" are shown in DE/EN. ## Nightly The nightly compares skipped stages exactly. An NVD outage now shows as `cve_lookup` in the report, not as a list of missing CVEs. ## Checked - `cargo fmt --all --check`. - clippy with the CI flags for compliance-agent and the dashboard (`server`, `web`). - Tests: agent 435, dashboard 49 / 33. They include: - a local NVD stand-in: rate-limited twice then answered, the second ask served from the cache, a lasting 429 is an error after four tries, a 404 is not retried; - a failed CVE lookup makes cra-ai-22 "not assessed" while memory safety is unaffected; - the DE reason text. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang force-pushed fix/nvd-lookups from 4937a79688 to ff79f72d29 2026-09-25 10:06:20 +00:00 Compare
sharang added 1 commit 2026-09-25 10:43:15 +00:00
fix(cve): NVD lookups retry, cache, and record what they missed (#387)
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 8m23s
3d88d48455
A rate-limited or failed NVD lookup made a scan quietly report fewer
CVEs. Lookups now retry with backoff and cache each product's answer
for six hours; what still fails is recorded on the run as the skipped
stage cve_lookup, and the CRA status no longer calls a control clean
when a tool it relies on did not complete.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang force-pushed fix/nvd-lookups from ff79f72d29 to 3d88d48455 2026-09-25 10:43:15 +00:00 Compare
sharang merged commit e399cea0b6 into main 2026-09-25 10:52:39 +00:00
Sign in to join this conversation.