X Tutup
Skip to content

fix(vulnfeeds): detect when version range has introduced >= fixed#4551

Open
Harshit28j wants to merge 3 commits intogoogle:masterfrom
Harshit28j:fix/issue-215-detect-invalid-version-range
Open

fix(vulnfeeds): detect when version range has introduced >= fixed#4551
Harshit28j wants to merge 3 commits intogoogle:masterfrom
Harshit28j:fix/issue-215-detect-invalid-version-range

Conversation

@Harshit28j
Copy link

Overview

Fixes #215

Added a check to detect when CVE data has invalid version ranges where the introduced version comes after the fixed version according to the validVersions ordering.

Details

Problem:

For PyPI vulnfeeds, there are cases of bad CVE data where introduced: 1.0 and fixed: 1.0b4. In Python versioning (PEP 440), 1.0b4 (beta) comes before 1.0 (final release), making this range logically impossible.

Visual Example of what I understood and assumed

❌ BAD DATA (triggers warning):
Version:    1.0a1   1.0a2   1.0b1   1.0b4   1.0rc1   1.0    1.1
Index:        0       1       2       3        4       5      6
                                      ↑               ↑
                                   fixed         introduced
                                   (idx 3)        (idx 5)

Problem: 5 >= 3 → introduced comes AFTER fixed (impossible!)

Solution:

Added a check in ExtractVersionInfo (vulnfeeds/cves/versions.go) that compares the positions of introduced and fixed versions in the validVersions slice. When introduced >= fixed, a warning is appended:

Result: Warning generated ⚠️

✅ GOOD DATA (no warning):

Version:    1.0a1   1.0a2   1.0b1   1.0b4   1.0rc1   1.0    1.1
Index:        0       1       2       3        4       5      6
              ↑                       ↑
         introduced                fixed
          (idx 0)                 (idx 3)

Result: 0 < 3 → Valid range ✅

Warning: introduced version 1.0 >= fixed version 1.0b4

Changes:

  • File: vulnfeeds/cves/versions.go
  • Lines added: 11
  • Uses existing versionIndex() function
  • Flow of code now:
image

Testing

  • All existing tests pass (go test ./cves/)
  • Verified manually with mock CVE data replicating the issue
  • Verified no false positives for valid version ranges
  • Verified graceful degradation when validVersions is empty

@jess-lowe
Copy link
Contributor

Great work. Would you mind adding a testcase to cover this change? Thanks!

@Harshit28j
Copy link
Author

@jess-lowe Added test cases and updated the branch since it was outdated.

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

This pull request has not had any activity for 60 days and will be automatically closed in two weeks

@github-actions github-actions bot added the stale The issue or PR is stale and pending automated closure label Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale The issue or PR is stale and pending automated closure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vulnfeeds: detect when version range has introduced > fixed

2 participants

X Tutup