Skip to content

feat(vulnfeeds): infer version ranges from comparison URLs - #6192

Open
Pushpak731 wants to merge 1 commit into
google:masterfrom
Pushpak731:compare-url-version-ranges
Open

Pushpak731 wants to merge 1 commit into
google:masterfrom
Pushpak731:compare-url-version-ranges

Conversation

@Pushpak731

Copy link
Copy Markdown

Description

A CVE reference that is a Git comparison URL with version-like tags on both sides, e.g.

https://github.com/JSONPath-Plus/JSONPath/compare/v9.0.0...v10.1.0
https://github.com/kovidgoyal/kitty/compare/v0.26.1...v0.26.2

now yields an introduced..fixed version range (the left side is where the affected range starts, the right side is where it is fixed — consistent with the existing assumption that reference links are fixes). This is attempted before the existing fallback of treating any commit reference as a fix, so comparison URLs are preferred for CVEs that have both (#2924). Like other version ranges, the result is then resolved to a Git commit range via the repository's tags, or recorded as an unresolved range when the tags can't be matched.

Conservative heuristics keep branch and commit comparisons out:

  • both sides must look like version tags (optional v prefix followed by a digit, and normalizable by git.NormalizeVersion)
  • commit-hash-like sides (e5dd0a3...8b4f5c2), wildcard branches (7.x-3.x), sides containing path separators and self-comparisons are rejected
  • three-dot and two-dot comparisons are both supported, on GitHub and GitLab-style (/-/compare/) URLs

The new REFERENCES_COMPARE version source records where these ranges came from in conversion metrics.

This should help the likes of CVE-2024-21534 convert in an un-analyzed state, as noted in the issue.

Testing

  • TestExtractVersionRangeFromCompareURL: 15 table-driven cases covering accepted forms (v-prefixed, unprefixed, two-dot, GitLab /-/compare/, trailing slash) and rejected ones (branch, wildcard branch, commit-hash, self-comparison, path side, missing side, non-compare URLs).
  • TestExtractVersionsFromCompareReference / TestExtractVersionsFromBranchCompareReference: end-to-end DefaultVersionExtractor.ExtractVersions tests using a pre-populated InMemoryRepoTagsCache and an offline HTTP transport, verifying the resolved Git range (introduced/fixed commits, repo, Range_GIT type) and the metrics source, and that branch comparisons produce nothing.
  • Verified regression coverage by mutation (disabling the compare parsing fails both new test groups); full vulnfeeds go test ./... passes locally (cmd/ids has a pre-existing CRLF-related failure on Windows that also fails on an unmodified checkout).

Fixes #2924

A CVE reference like
kovidgoyal/kitty@v0.26.1...v0.26.2
now yields an introduced..fixed version range (preferred over the
commit-reference-as-fix fallback), which then resolves to a commit
range via the repository's tags like any other version range.

Branch comparisons, commit comparisons and wildcard branches are
rejected by conservative heuristics on the two sides.

Fixes google#2924

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vulnfeeds: infer introduced and fixed versions from a GitHub compare URL

1 participant