vulns/osv_export: deduplicate references from OSV.dev - #23314
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request improves the OSV export generated by brew generate-vulns-advisories by removing duplicate references entries coming from OSV.dev when the same URL appears multiple times under the same reference type due to differing percent-encoding (e.g. %40 vs @).
Changes:
- Deduplicate upstream
referencesby[type, decoded_url], while preserving entries where the same URL appears under differenttypevalues. - Add a focused spec that covers the percent-encoding deduplication behavior and ensures distinct types are retained.
- Tighten the spec file to
# typed: strictand adjust theseedhelper to avoid strict-Sorbet method signature requirements.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Library/Homebrew/vulns/osv_export.rb | Deduplicates upstream OSV reference URLs by normalising percent-encoding for comparison while retaining type distinctions. |
| Library/Homebrew/test/vulns/osv_export_spec.rb | Adds coverage for the new deduplication logic and updates the spec to typecheck under typed: strict. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
OSV.dev merges NVD and cve.org reference lists without normalising percent-encoding, so a URL like the Fedora package-announce archive can appear once as %40 and once as @ under the same reference type. Collapse those on the way out while preserving the same URL under distinct types, which the schema allows and which carries meaning. Use `URI::RFC2396_PARSER.unescape` to match existing usage in `AbstractFileDownloadStrategy`; it leaves literal + alone and passes invalid %XX through unchanged rather than raising.
andrew
force-pushed
the
vulns-osv-export-dedup-references
branch
from
July 26, 2026 18:21
5711dbd to
f6403c5
Compare
andrew
enabled auto-merge
July 26, 2026 18:22
p-linnane
approved these changes
Jul 26, 2026
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.
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?I used Claude Code to draft the patch and test after spotting duplicate reference URLs in Homebrew/advisory-database#24. I reviewed the diff, confirmed the OSV.dev response contains the duplicates, and checked that keying on
[type, decoded_url]preserves legitimate same-URL-different-type entries in the existing advisory set.brew generate-vulns-advisoriescopies thereferencesarray fromGET https://api.osv.dev/v1/vulns/{id}verbatim into the emitted OSV record. OSV.dev merges NVD and cve.org reference lists without normalising percent-encoding, so the same URL can appear twice under the sametype:which then lands in the generated advisory (Homebrew/advisory-database#24).
This dedups on
[type, URI::RFC2396_PARSER.unescape(url)]so%40/@collapse while the same URL under distincttypevalues (e.g.ADVISORYvsREPORT, which OSV.dev also emits and the schema allows) is kept.RFC2396_PARSER.unescapematches existing usage inAbstractFileDownloadStrategy, leaves literal+in paths alone (Launchpad+bug/URLs), and passes invalid%XXsequences through unchanged rather than raising.To reproduce before this change: