Fix false-positive vulnerability detection for Go pseudo-versions#14591
Draft
Copilot wants to merge 3 commits into
Draft
Fix false-positive vulnerability detection for Go pseudo-versions#14591Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
When a Go module doesn't follow the /vN import path convention (e.g., github.com/hyperledger/fabric has v3.x tags but no /v3 path), Go generates pseudo-versions anchored to the highest reachable v1.x tag. The synthetic v1.x semver would incorrectly match advisories whose fix is in a different major version. This change: - Adds Version.pseudo_version? for centralized detection - Overrides vulnerable? in GoModules::UpdateChecker to skip advisories whose safe (fix) versions are all in a different major version than the pseudo-version's base - Preserves existing behavior for pseudo-versions without safe_versions and same-major advisories - Removes duplicated PSEUDO_VERSION_REGEX from LatestVersionFinder and PackageDetailsFetcher in favor of Version.pseudo_version? Agent-Logs-Url: https://github.com/dependabot/dependabot-core/sessions/92a8f914-3fa6-4fc0-aafb-6d907139e1b1 Co-authored-by: Nishnha <12107187+Nishnha@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dependabot/dependabot-core/sessions/92a8f914-3fa6-4fc0-aafb-6d907139e1b1 Co-authored-by: Nishnha <12107187+Nishnha@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dependabot/dependabot-core/sessions/92a8f914-3fa6-4fc0-aafb-6d907139e1b1 Co-authored-by: Nishnha <12107187+Nishnha@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
Nishnha
March 31, 2026 15:37
View session
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.
What are you trying to accomplish?
Go pseudo-versions like
v1.4.0-rc1.0.20250929141436-dad09ab05b71produce false-positive security alerts when a module doesn't follow Go's/vNimport path convention. For example,github.com/hyperledger/fabrichas v3.x tags but no/v3path, so Go anchors the pseudo-version to the highest v1.x tag. TheGoModules::Versionclass strips this to base1.4.0, which satisfies advisory ranges like< 2.2.14— triggering a vulnerability alert for code that's actually past the fix.Root cause:
SecurityAdvisory#vulnerable?compares the synthetic semver base against advisory ranges. This is correct for tagged releases but unreliable for pseudo-versions when the advisory's fix is in a different major version.Fix: When the dependency version is a pseudo-version, filter out advisories whose safe (fix) versions are all in a different major version than the pseudo-version's base. This preserves vulnerability detection for:
safe_versions(conservatively flagged)Anything you want to highlight for special attention from reviewers?
The key design decision is when to skip an advisory for pseudo-versions. The approach uses the advisory's
safe_versionsmajor as the discriminator:If
safe_versionsis empty (onlyvulnerable_versionsspecified), we conservatively treat the pseudo-version as vulnerable since we can't determine the fix version's major. This is a tradeoff — it avoids false negatives for advisories that don't specify fix versions.The existing test for
v0.0.0-20180826012351-8a410e7b638dwith advisory< 1.0.1(nosafe_versions) continues to pass — that pseudo-version is correctly flagged as vulnerable.Also consolidated the duplicated
PSEUDO_VERSION_REGEXfromLatestVersionFinderandPackageDetailsFetcherintoVersion.pseudo_version?. The regex inPackageDetailsFetcherwas dead code.How will you know you've accomplished your goal?
New test cases cover the key scenarios:
v1.4.0-rc1.0...+ safe>= 2.2.14) →vulnerable?returnsfalsev1.2.0-0...+ safe>= 1.3.0) → returnstruev1.4.0-rc1.0...+ only vulnerable< 2.2.14) → returnstrue(conservative)>= 1.5.0OR>= 2.2.14) → returnstrue(fix exists in same major)v0.0.0-...) still passesAll 110 tests pass (0 failures, 6 pre-existing pending). Rubocop clean.
Checklist