Repository navigation
fix(osv): emit any-version entry when an affected entry also lists versions - #91
Open
RyoKusnadi wants to merge 1 commit into
Open
RyoKusnadi wants to merge 1 commit into
RyoKusnadi wants to merge 1 commit into
Conversation
…rsions Signed-off-by: Ryo Kusnadi <ryokusnadi@gmail.com>
Author
|
@adel-pplx friendly ping on this one when you have a moment. Happy to change anything. |
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.
Problem
When an OSV record lists
versionsand also has a range of just{"introduced": "0"},osvcatalogwrites only the listed versions. Any other published version of the package, including one npm has since removed, is not matched. The issue counts 15 of 82 records in one refresh with this shape, all npm.How it happens: a malicious-package record such as MAL-2026-18437 (
atlassian-wallboard-plugin) carries"ranges": [{"type": "SEMVER", "events": [{"introduced": "0"}]}]and"versions": ["10.0.0"]in the sameaffectedentry. OSV defines the affected set as the union ofrangesandversions, andintroduced: "0"with nofixedalready means every version.Cause
In
Convert(internal/osv/osv.go),a.allVersions()was only checked whenlen(a.Versions) == 0. With a non-emptyversionslist, the range was never looked at.Fix
Check
a.allVersions()first and emit["*"]whether or notversionsis set. An entry with only a bounded range and no versions is still skipped, as before. I did not changeallVersions()itself; it already accepts onlyintroduced: "0"ranges.Scope
Convertis the only caller ofallVersions(). The existing aggregation across severalaffectedentries for one package already let an all-versions entry win; this makes the single-entry case behave the same way.Testing
Added
TestConvertAllVersionsWithListedVersionsInOneEntryininternal/osv/osv_test.go.want single [*] entry, got [{ID:MAL-both ... Versions:[10.0.0] ...}].Commands run:
go vet ./internal/osv/,go test ./internal/osv/ ./tools/...,gofmt -l internal/osv(no output). Not run: the full./...suite and-race.Risk
Generated catalogs now contain
["*"]for these packages, so every version of them is flagged. That is whatintroduced: "0"declares. Regenerating a catalog is the only effect; revert the commit to roll back.Fixes #90