feat(ubuntu): capture Notes section from Ubuntu security data (#1126)#1163
Open
ChrisJr404 wants to merge 1 commit into
Open
feat(ubuntu): capture Notes section from Ubuntu security data (#1126)#1163ChrisJr404 wants to merge 1 commit into
ChrisJr404 wants to merge 1 commit into
Conversation
…e#1126) The Ubuntu security tracker format includes a free-form Notes: block where Canonical analysts record context like why a package isn't affected, why a fix is deferred, mitigation observations, etc. The provider was throwing this away. This change parses each note in the Notes: section into a (author, text) tuple, carries it on the in-memory CVEFile, persists it through the merged JSON written to disk, and includes it in the Vulnerability record produced for each affected namespace so grype (or any other consumer of the os schema output) can surface the analyst's commentary next to findings. The Notes attribute is only emitted on the JSON record when at least one note was parsed. Empty Notes: blocks (the common case) leave the existing record shape unchanged, so this is a non-breaking addition for downstream consumers. Notes block format handled: Notes: author> first line of the note continuation of the same note author2> another note > authorless note The parser tolerates missing author prefixes, trailing blank lines, and notes that span any number of continuation lines. Signed-off-by: ChrisJr404 <chris@hacknow.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes #1126.
The Ubuntu security tracker entries include a
Notes:section where Canonical analysts add free-form context: why a package isn't affected, why a fix is deferred, the rationale for a priority assignment, mitigation observations, and so on. The vunnel provider parses Ubuntu CVE files but currently discards everything in this section.This PR captures that content end-to-end:
parse_notes()parses theNotes:block into(author, text)pairs.Notedataclass carries each note on the in-memoryCVEFile._merge_cve/_load_merged_cve.map_parsed()attaches them to each affected-namespaceVulnerabilityrecord so the JSON written by the provider includes them, ready for grype (or any other consumer of the os vulnerability schema) to surface alongside findings.Format handled
The parser tolerates missing author prefixes, blank intra-section lines, and continuation lines on any indent depth deeper than the author line.
Output shape
When the upstream entry has notes, the produced JSON gains a
Notesfield on theVulnerabilityobject:{ "Vulnerability": { "Name": "CVE-2024-3094", "NamespaceName": "ubuntu:24.04", "Notes": [ { "author": "mdeslaur", "text": "The affected version of xz-utils was only in noble-proposed, and was removed before migrating to noble itself. No released versions of Ubuntu were affected by this issue." }, { "author": null, "text": "Priority reason: Results in a backdoor in sshd" } ], "...": "..." } }The
Noteskey is only emitted when at least one note was parsed. EmptyNotes:blocks (the common case) leave the existing record shape untouched, which means existing snapshots in this repo still match and downstream consumers don't see a churn of empty arrays. The os vulnerability schema does not pinadditionalProperties, so this is additive without a schema bump.The grype-side schema is intentionally not changed in this PR — the issue calls out that grype consumption is a follow-up, and this PR just gets the data flowing into the vunnel intermediate.
Tests
Added eight unit tests covering:
Notes:block (yields[])Notes:block (example_ubuntu_cve_with_notes)example_ubuntu_cvefixture (empty Notes) still parses tonotes == []asdict/from_dictround trip preserves notesmap_parsedemitsNoteson the JSON record when presentmap_parsedomitsNotesfrom the JSON record when no notes were parsed (snapshot stability)The existing snapshot test (
test_provider_via_snapshot) still passes against the unmodified snapshots since none of the fast-export fixtures have populated notes.Test plan
uv run pytest tests/unit/providers/ubuntu/— 46 / 46 passuv run pytest tests/unit/— 834 / 834 passuv run ruff check src/vunnel/providers/ubuntu/parser.py tests/unit/providers/ubuntu/test_ubuntu.py— only pre-existing project-wide warnings (S101 pytest assertions, A001 in unrelated tests); no new errors introduceduv run ruff formatapplied