Skip to content

fix: Improve OSV source version handling for ecosystem-specific formats#5503

Open
VanitasCodes wants to merge 2 commits intoossf:mainfrom
VanitasCodes:fix/osv-ecosystem-version-handling
Open

fix: Improve OSV source version handling for ecosystem-specific formats#5503
VanitasCodes wants to merge 2 commits intoossf:mainfrom
VanitasCodes:fix/osv-ecosystem-version-handling

Conversation

@VanitasCodes
Copy link
Copy Markdown
Contributor

@VanitasCodes VanitasCodes commented Jan 17, 2026

Summary

Fixes incorrect handling of product versions from OSV source data by addressing ecosystem-specific version formats.

Fixes #3201
Related: #4953, #4954

Changes

The main issue was that ecosystem-specific version strings (like Debian's 1:9.2p1-2) were being stored directly in the database, which broke version comparisons against upstream versions like 9.6p1.

This PR:

  • Skips Android and Linux ecosystems entirely since their version formats don't correspond to actual package versions (e.g., 12L:2022-09-01 for expat)
  • Normalizes Debian versions by stripping the epoch and revision (1:9.2p1-29.2p1)
  • Normalizes Alpine versions by stripping the release suffix (2.4.1-r02.4.1)
  • Prefers SEMVER ranges over ECOSYSTEM ranges when both are available
  • Falls back to the versions list when range events don't have fix information

Testing

Updated the existing test_format_data expectations and added two new test classes covering version normalization and ecosystem handling.

Copilot AI review requested due to automatic review settings January 17, 2026 08:28
@VanitasCodes VanitasCodes force-pushed the fix/osv-ecosystem-version-handling branch from 7910e56 to b50e4c8 Compare January 17, 2026 08:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes incorrect handling of product versions from OSV source data by addressing ecosystem-specific version formats. The main issue was that ecosystem-specific version strings (like Debian's 1:9.2p1-2) were being stored directly in the database, breaking version comparisons against upstream versions.

Changes:

  • Adds ecosystem filtering to skip Android and Linux ecosystems where version formats don't correspond to upstream package versions
  • Implements version normalization for Debian (strips epoch and revision) and Alpine (strips release suffix) formats
  • Fixes duplicate ranges bug by creating separate entries for each introduced/fixed pair instead of overwriting
  • Improves range selection logic to prefer SEMVER over ECOSYSTEM ranges and fall back to versions list when fix information is absent

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cve_bin_tool/data_sources/osv_source.py Implements ecosystem filtering, version normalization, and improved range handling logic
test/test_source_osv.py Updates test expectations and adds comprehensive test coverage for version normalization and ecosystem handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@VanitasCodes
Copy link
Copy Markdown
Contributor Author

@ffontaine I was wondering if you could have a look at this one and see if I need to make any adjustments.

@alex-ter
Copy link
Copy Markdown
Collaborator

This should generally wait until the more foundational changes are done in #4956 and then be rebased on top of it.

@VanitasCodes VanitasCodes force-pushed the fix/osv-ecosystem-version-handling branch from 452cf11 to 32ddfc2 Compare February 28, 2026 18:49
@ffontaine
Copy link
Copy Markdown
Collaborator

#4956 has been merged, rebase is needed to fix conflicts

@VanitasCodes VanitasCodes force-pushed the fix/osv-ecosystem-version-handling branch 2 times, most recently from 25772df to 6b31545 Compare March 1, 2026 10:49
@VanitasCodes VanitasCodes requested a review from Copilot March 1, 2026 10:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@VanitasCodes VanitasCodes force-pushed the fix/osv-ecosystem-version-handling branch from f7a828f to b225458 Compare March 29, 2026 23:48
@VanitasCodes
Copy link
Copy Markdown
Contributor Author

@alex-ter Ready for review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@VanitasCodes VanitasCodes force-pushed the fix/osv-ecosystem-version-handling branch 2 times, most recently from 343b3e3 to 4099e91 Compare March 30, 2026 13:56
@VanitasCodes VanitasCodes requested a review from Copilot March 30, 2026 16:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@alex-ter alex-ter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment inline, otherwise LGTM by inspection.

Signed-off-by: Vishwajeet Singh <mit.vs.krishna@gmail.com>
@VanitasCodes VanitasCodes force-pushed the fix/osv-ecosystem-version-handling branch from 4099e91 to 3885804 Compare April 6, 2026 19:43
@VanitasCodes
Copy link
Copy Markdown
Contributor Author

@alex-ter Addressed the change, ready for review.

@VanitasCodes VanitasCodes requested a review from alex-ter April 6, 2026 19:45
@VanitasCodes
Copy link
Copy Markdown
Contributor Author

@ffontaine The CI failures here are unrelated to my changes. I only removed two redundant lines and these failures weren't present when I last pushed.

The check-spelling failure is a GitHub Actions workflow infrastructure issue. The test_refresh_nvd_json failure is caused by corrupt data on the NVD mirror. I'm unsure as to why the tests are failing.

@ffontaine
Copy link
Copy Markdown
Collaborator

To fix check-spelling, a bump to version 0.0.26 is needed (see https://docs.check-spelling.dev/Feature:-Restricted-Permissions). I'll then update your branch

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.

Incorrect handling of product versions from OSV source

4 participants