Repository navigation
fix: ingest Go advisories in GitHub importers - #2560
Open
Naman-Katiyar wants to merge 2 commits into
Open
Naman-Katiyar wants to merge 2 commits into
Naman-Katiyar wants to merge 2 commits into
Conversation
Enable the GO ecosystem in the GitHub API importer and golang in the GitHub OSV v2 importer so Go advisories are collected instead of skipped. The downstream parsing already supports golang: get_purl handles golang packages, univers provides GolangVersionRange, and the OSV v2 parser maps the Go ecosystem to golang PURLs. resolves: aboutcode-org#1039 Signed-off-by: Naman Katiyar <namankatiyar120@gmail.com>
Add regression tests asserting that the GitHub API importer queries the GO ecosystem and yields golang packages, and that the GitHub OSV v2 importer keeps affected packages for Go advisories. Both tests fail without the ecosystem enablement and pass with it. Signed-off-by: Naman Katiyar <namankatiyar120@gmail.com>
This branch has not been deployed
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.
Fixes #1039
Summary
Go advisories from GitHub sources were not being ingested because the Go ecosystem was disabled in both GitHub importers:
GitHubAPIImporterPipeline.package_type_by_github_ecosystemhad the"GO": "golang"mapping commented out, so the GitHub GraphQL API was never queried for the GO ecosystem.GithubOSVImporterPipelinehad"golang"commented out of its supported ecosystems, so Go advisories from the GitHub Advisory Database were parsed but their affected packages were dropped as unsupported.This PR enables the Go ecosystem in both importers. The downstream handling already supports golang:
get_purlhandles golang packages,universprovidesGolangVersionRangefor the advisory version ranges, and the OSV v2 parser already maps the Go ecosystem to golang PURLs (PURL_TYPE_BY_OSV_ECOSYSTEM). This is the Go slice of #1039; the other ecosystems discussed there are either already ingested or not supported yet.Test report
I added two regression tests:
test_collect_advisories_includes_golang_ecosysteminvulnerabilities/tests/pipelines/test_github_importer_pipeline.py: mocks the GitHub GraphQL fetch, runscollect_advisories, and asserts that the GO ecosystem is queried and that the yielded advisories carry golang packages.test_collect_advisories_from_github_osv_golanginvulnerabilities/tests/pipelines/v2_importers/test_github_osv_importer_v2.py: feeds a Go OSV advisory throughcollect_advisoriesand asserts that its affected package is kept with typegolang.Fail-before / pass-after evidence:
assert 'GO' in ['MAVEN', 'NUGET', 'COMPOSER', 'PIP', 'RUBYGEMS', 'NPM', 'RUST']), and the Go OSV advisory yieldsaffected_packages == []with an "Unsupported package type" log.Validation run locally with pytest:
vulnerabilities/tests/pipelines/test_github_importer_pipeline.py: 16 passed (including the existing parametrizedprocess_responsetests for all ecosystems, golang included).vulnerabilities/tests/pipelines/v2_importers/test_github_osv_importer_v2.pyandvulnerabilities/tests/test_github_osv.py: 10 passed.vulnerabilities/tests/test_osv.py: 24 passed.Changed files are formatted with black and isort.