feat(ecosystems): add Homebrew ecosystem and pkg:brew purl mapping#5660
Draft
andrew wants to merge 1 commit into
Draft
feat(ecosystems): add Homebrew ecosystem and pkg:brew purl mapping#5660andrew wants to merge 1 commit into
andrew wants to merge 1 commit into
Conversation
Add Homebrew as an OrderedEcosystem with a version comparator that ports Homebrew's PkgVersion/Version#<=> (tokenised two-pointer walk with alpha/beta/pre/rc below the release, string/patch/post above, numeric zero equal to a missing token, then _N revision as a numeric tie-breaker) and a coarse_version over the leading numeric prefix. Map the ecosystem to the pkg:brew purl type (no namespace) and add formulae.brew.sh as the package_urls entry. Comparison test cases are lifted from Homebrew's own version_spec.rb; a hypothesis strategy covers coarse-version monotonicity. Refs google#5659 Signed-off-by: Andrew Nesbitt <andrewnez@gmail.com>
33 tasks
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.
Overview
Add the
Homebrewecosystem to_ecosystems.pywith aPkgVersioncomparator, and map it to thepkg:brewpurl type inpurl_helpers.py, soBREW-*records from https://github.com/Homebrew/advisory-database can be queried by version and purl once imported.Refs #5659
Details
osv/ecosystems/homebrew.pyports Homebrew'sPkgVersionandVersion#<=>as afunctools.total_orderingclass: the version segment is tokenised into numeric / prerelease-marker (alpha/beta/pre/rc) / patch-marker (p/.post) / string parts and compared with the same two-pointer walk (prerelease below the release, string/patch/post above, numeric zero equal to a missing token so2.1.0-p194and2.1-p194align), then the numeric_Nrevision suffix breaks ties.Homebrewis anOrderedEcosystem(no version enumeration; formulae.brew.sh only exposes the current version) with acoarse_versionover the leading numeric prefix.pkg:brew(registered in package-url/purl-spec#796) maps toHomebrewwith no namespace. TheHomebrewecosystem andBREW-prefix were registered in ossf/osv-schema#576.I've kept this to the Python side per the new-data-source docs; happy to add the Go entries in
go/osv/ecosystem/andgo/purl/here or in a follow-up if preferred.Testing
osv/ecosystems/homebrew_test.py: 51 comparison cases lifted from Homebrew's owntest/version_spec.rbplus_Nrevision cases; registration/sort/coarse checks.osv/ecosystems/coarse_version_monotonicity_test.py: hypothesis strategy for realistic Homebrew version strings; monotonicity property holds.osv/purl_helpers_test.py:pkg:brew/openssl%403@3.5.0round-trips.poetry run python -m unittest osv.ecosystems.homebrew_test osv.purl_helpers_test osv.ecosystems.coarse_version_monotonicity_test osv.ecosystems._ecosystems_test— 26 tests pass.poetry run pylinton all touched files: 10.00/10.yapf -dclean.This PR was drafted with AI assistance (Claude Code); I read the diff, verified the comparison table against
version_spec.rb, and ran the tests locally.