fix(vulns): GHSA advisory references are string-array, not [{url}] (repairs enrichment)#110
Open
msitarzewski wants to merge 1 commit into
Open
fix(vulns): GHSA advisory references are string-array, not [{url}] (repairs enrichment)#110msitarzewski wants to merge 1 commit into
msitarzewski wants to merge 1 commit into
Conversation
The global advisories endpoint (`GET api.github.com/advisories/{id}`) returns
`references` as an array of plain URL STRINGS, but both the Rust enrich layer
and its Swift port modeled it as `[{ "url": … }]` objects. Consequences:
- Rust: a present-but-wrong-type `references` made the WHOLE `RawAdvisory`
parse fail, so `fetch_advisory_with` returned `Ok(None)` — GHSA enrichment
was a silent no-op for essentially every advisory (latent since v0.5.0).
- Swift: tolerant per-field decode kept summary/details/fixed-in working but
silently dropped all references.
Both `RawReference` parsers now accept BOTH shapes (untagged enum in Rust, a
custom decoder in Swift) so neither endpoint variant nor a future change can
silently disable enrichment again.
Root cause of the miss: the unit-test fixtures used the invented `[{url}]`
shape — the same wrong assumption as the code — so they passed against a shape
the real API never sends. Fixtures are now corrected to the REAL captured
shape (string array), plus a both-shapes regression test in each shell.
Tests: cargo enrich 17, swift 171 (each +1). clippy clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Live verification (fetching a real advisory from
api.github.com) caught a latent parser bug.The bug
GET /advisories/{ghsa_id}returnsreferencesas an array of plain URL strings:…but both parsers modeled it as
[{ "url": … }]objects.enrich.rs, since v0.5.0): a present field with the wrong element type makes the wholeRawAdvisorydeserialize fail →fetch_advisory_withreturnsOk(None)→ GHSA enrichment was a silent no-op for any advisory with references (≈ all of them).VulnsEnrich.swift): tolerant per-field decode kept summary/details/fixed-in working but silently dropped all references.The fix
RawReferencenow accepts both shapes — an untagged enum in Rust, a custom decoder in Swift — so neither the real string shape nor the object shape (nor a future change) can silently break enrichment.Why we missed it
The unit-test fixtures used the invented
[{url}]shape — the same wrong assumption as the code — so they validated a shape the real API never sends. Fixtures are now corrected to the real captured shape (string array), plus a both-shapes regression test in each shell.Tests
cargo enrich 17, swift 171 (each +1). clippy clean.
🤖 Generated with Claude Code