Fix OSV report generation fallback value for 'introduced' version from "0.0.0" to "0" #532
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.
Summary
Fixes issue #528 by updating the OSV report generation logic to use "0" instead of "0.0.0" as the fallback value for the 'introduced' version when empty, ensuring compliance with the OSV schema.
Problem
The current implementation in
pkg/malysis/ossf.go
sets the fallback value for the OSV vulnerability 'introduced' version to "0.0.0" when no explicit version is provided. According to the OSV (Open Source Vulnerability) schema specification, the correct fallback value should be "0", which represents "the vulnerability is present from the beginning of the version history".Changes
Code Changes
pkg/malysis/ossf.go
: Changed fallback value from"0.0.0"
to"0"
on line 70Test Changes
pkg/malysis/ossf_test.go
: Added new test casedefault_introduced_version_should_be_'0'_not_'0.0.0'
VersionIntroduced
is empty, the generated OSV report uses "0" as the introduced versionvuln.Affected[0].Ranges[0].Events[0].Introduced
fieldBefore/After
Before:
After:
Verification
Impact
This is a minimal, surgical change that:
The change only affects the default fallback behavior when no
VersionIntroduced
is explicitly provided in theOpenSSFMaliciousPackageReportParams
.Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
api.npmjs.org
/tmp/go-build2646479142/b1328/readers.test -test.testlogfile=/tmp/go-build2646479142/b1328/testlog.txt -test.paniconexit0 -test.v=true -test.timeout=5m0s
(dns block)https://api.github.com/repos/safedep/vet/contents/README.md
/tmp/go-build2646479142/b1328/readers.test -test.testlogfile=/tmp/go-build2646479142/b1328/testlog.txt -test.paniconexit0 -test.v=true -test.timeout=5m0s
(http block)https://api.github.com/repos/safedep/vet/contents/docs
/tmp/go-build2646479142/b1328/readers.test -test.testlogfile=/tmp/go-build2646479142/b1328/testlog.txt -test.paniconexit0 -test.v=true -test.timeout=5m0s
(http block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.