Repository navigation
Treat single Tomcat pre-release versions as exact versions - #2531
nikolya-ctrl wants to merge 2 commits into
Conversation
Versions like 11.0.0-M5 or 8.0.0-RC1 were split on '-' as A-B ranges. Only treat '-' as a range when the right side starts with a digit, in both to_version_ranges_apache and to_version_ranges_maven. Add tests. Fixes aboutcode-org#2528 Signed-off-by: Nikolya Fernando <238961989+nikolya-ctrl@users.noreply.github.com>
Jean-Regis-M
left a comment
There was a problem hiding this comment.
Tested on this branch (Windows, pytest, no DB): test_apache_tomcat_importer_pipeline.py 8 passed.
Behaviour on current main for a single milestone version vs this PR:
11.0.0-M5: main givesvers:apache/>=11.0.0(andvers:maven/<=M5|>=11.0.0), so everything from 11.0.0 up reads as affected. This PR givesvers:apache/11.0.0-M5.<10.1.0-M3: main givesvers:maven/<=M3|>=<10.1.0. This PR takes the<branch and gives<10.1.0-M3.- Real ranges (
8.5.0-8.5.50,11.0.0-M1 to 11.0.0-M5) come out the same as before.
One edge: version_item.split("-")[-1][0] raises IndexError on a trailing hyphen (7.0.0-). On main that case produces a junk range, here the exception reaches the except in the importer loop and the whole CVE entry is skipped. Unlikely on the real page, but [-1][:1].isdigit() avoids it.
With #2534 applied on top, the milestone fixed version and the single-version affected range line up (vers:apache/11.0.0-M5|!=11.0.0-M6). The two PRs only conflict in the test file, since both append at the end.
Use [:1] instead of [0] when checking the part after '-', so a value like '7.0.0-' no longer raises IndexError. Add a test. Suggested in review of aboutcode-org#2531. Signed-off-by: Nikolya Fernando <238961989+nikolya-ctrl@users.noreply.github.com>
|
Thanks for testing this so thoroughly, @Jean-Regis-M! Good catch on the trailing hyphen. I switched both checks to Also thanks for checking it together with #2534. I'll rebase whichever one is merged second to resolve the test file conflict. |
Fixes #2528
Problem
In
apache_tomcat_importer.py, bothto_version_ranges_apacheandto_version_ranges_maventreated any version containing-as anA-Brange. Single pre-release versions like11.0.0-M5or8.0.0-RC1were split into>=11.0.0and<=M5, so the affected pre-release was marked as not affected and later stable releases were marked as affected.Fix
Only treat
-as a range when the part after the dash starts with a digit (e.g.7.0.0-7.0.53). Otherwise the value falls through to the existing single-version branch.Tests
Added tests for:
7.0.0-7.0.53) to make sure existing behaviour is unchanged11.0.0-M5and8.0.0-RC1(Apache)11.0.0-M5(Maven)All 8 tests in
test_apache_tomcat_importer_pipeline.pypass locally (Python 3.13, WSL Ubuntu).Before / after (reproduction script from the issue)
Before:
After:
Note
The
!=11.0.0in the output comes from how the fixed version (11.0.0-M6) is handled, which looks like a separate issue, so I left it out of this PR. Happy to look into it separately if that's useful.I reproduced the bug, worked out the fix, implemented it with tests, and verified everything locally. I used an AI assistant as a learning aid while getting familiar with the codebase and to help word this description.