Skip to content

feat(parsers): add Yocto CVE Check JSON parser - #16906

Open
skywalke34 wants to merge 1 commit into
DefectDojo:devfrom
skywalke34:yocto-cve-check-parser
Open

skywalke34 wants to merge 1 commit into
DefectDojo:devfrom
skywalke34:yocto-cve-check-parser

Conversation

@skywalke34

Copy link
Copy Markdown
Contributor

Description

Adds a parser for the CVE manifest that the Yocto Project writes for an embedded Linux image (scan type Yocto CVE Check). It covers both writers of the format:

  • the cve-check class in OpenEmbedded-Core, Yocto 3.1 (dunfell) through 5.3 (whinlatter);
  • sbom-cve-check, which replaced cve-check in Yocto 6.0 and writes the same manifest by default (yocto-cve-check-manifest export).

The format and every mapping decision were checked against the upstream writers on each release branch, not against documentation alone.

How Yocto's per-CVE status is mapped:

Yocto status DefectDojo
Unpatched, Unknown, null Active finding
Patched Skipped (fixed in the build; Yocto lists hundreds per image)
Ignored, detail upstream-wontfix Active finding (the vulnerable code is still present)
Ignored, any other detail Closed as mitigated, with Yocto's reason in mitigation

Ignored closes as mitigated rather than as false positive or out of scope on purpose. Reimport never reopens a false-positive or out-of-scope finding, so a CVE that a later build reports as Unpatched again (for example after a kernel config change) would stay hidden. Mitigated round-trips in both directions, and the tests cover that through the real importer and reimporter.

Severity comes from the newest CVSS version that has a score (v4, v3, v2). The vectorString is used, through parse_cvss_data, only when it belongs to that version. The NVD database used by cve-check up to scarthgap keeps the CVSS v2 vector whenever one exists, so an older CVE often carries a v2 vector next to a v3 score. Trusting that vector would grade a 9.8 CVE as High. Unscored CVEs are Info, as in the Trivy and Grype parsers.

Deduplication is hash-code on vuln_id_from_tool, component_name and component_version, the same fields as CycloneDX, SPDX and OpenVEX.

Test results

unittests/tools/test_yocto_cve_check_parser.py has 30 tests, run under PYTHONWARNINGS=error. They cover:

  • 0, 1 and many findings.
  • Fixtures shaped like each upstream writer: kirkstone-era without a vector, scarthgap NVD2 with a v2 vector next to a v3 score, whinlatter's field set with Unknown status and issues without NVD data, and the sbom-cve-check export.
  • Severity from v2, v3 and v4 data, and every Ignored detail.
  • Description escaping, values longer than the model columns, BOM input, non-string values, and malformed files raising ValueError.
  • TestYoctoCveCheckReimport, which runs DefaultImporter and DefaultReImporter through Unpatched → Ignored → Unpatched → Patched, and Ignored → Unpatched.

unittests.test_parsers passes and ruff check is clean. All sample data is fabricated: the package names are real Yocto recipes, and the CVE-2025-9000x and CVE-2026-9000x IDs are placeholders.

Not tested: a manifest from a real Yocto build. The fixtures were built from the upstream writer source.

Documentation

docs/content/supported_tools/parsers/file/yocto_cve_check.md covers how to produce the manifest on each release, the field mapping, the status and severity rules, and deduplication.

Checklist

  • Rebased against the very latest dev.
  • Submitted against the dev branch.
  • Meaningful PR name.
  • Ruff compliant.
  • Python 3.13 compliant.
  • Documentation included.
  • No model changes, so no migrations.
  • Unit tests added.
  • Labelled Import Scans.

Generated with Claude Code under the direction of T. Walker (skywalke34) - DefectDojo

Import the CVE manifest written by the Yocto Project's cve-check class
(dunfell through whinlatter) and by sbom-cve-check, its replacement from
Yocto 6.0, which writes the same format by default.

- Unpatched (and Unknown/null) CVEs become active findings; Patched CVEs
  are skipped.
- Ignored CVEs close as mitigated, with Yocto's reason in the mitigation
  field, so reimport reopens them if a later build reports them
  Unpatched. upstream-wontfix stays active.
- Severity comes from the newest scored CVSS version. The vector is used
  only when it belongs to that version, because the NVD database behind
  cve-check up to scarthgap keeps the v2 vector whenever one exists.
- Hash-code dedup on vuln_id_from_tool, component_name and
  component_version, as for CycloneDX, SPDX and OpenVEX.

Authored by T. Walker - DefectDojo

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant