Skip to content

Preserve affected packages when OSV range has only introduced:0 (#2535) - #2543

Open
sumitkhond111-del wants to merge 1 commit into
aboutcode-org:mainfrom
sumitkhond111-del:fix-osv-v2-introduced-zero-2535
Open

sumitkhond111-del wants to merge 1 commit into
aboutcode-org:mainfrom
sumitkhond111-del:fix-osv-v2-introduced-zero-2535

Conversation

@sumitkhond111-del

Copy link
Copy Markdown

No description provided.

…tcode-org#2535)

Signed-off-by: sumitkhond111-del <sumitkhond111@gmail.com>
@sumitkhond111-del

Copy link
Copy Markdown
Author

Fixes #2535

Summary

  • Updated get_version_ranges_constraints() in vulnerabilities/pipes/osv_v2.py to retain introduced == "0" and emit VersionConstraint(comparator=">=", version=zero_intro_v_obj) (vers:<ecosystem>/>=0) when a range has no other affected constraints (no fixed, last_affected, or non-zero introduced events), preventing parse_advisory_data_v3() from dropping AffectedPackageV2 entries.
  • Preserved existing behavior when fixed or last_affected events are present.
  • Added test_parse_advisory_data_v3_introduced_zero_only in vulnerabilities/tests/pipes/test_osv_v2.py.

Testing

  • pytest vulnerabilities/tests/pipes/test_osv_v2.py -q → 19 passed.

@Jean-Regis-M Jean-Regis-M left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ran this at 7ce0701 through parse_advisory_data_v3 over all 7,943 advisories in pypa/advisory-database.

30 of them change. Each one goes from no affected package on main to vers:pypi/>=0, for example PYSEC-2024-266 (apache-airflow). None of the 30 has an explicit versions list, so nothing that was listed gets widened.

I also fed a record with only {"introduced": "0"} through every ecosystem. pypi, npm, nuget, gem, golang, hex and composer now keep the package. None of them did on main.

The OSV and PyPA/GitHub importer tests pass (27, against 26 on main).

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.

2 participants