Skip to content

Keep milestone suffix in Tomcat fixed versions - #2534

Open
nikolya-ctrl wants to merge 2 commits into
aboutcode-org:mainfrom
nikolya-ctrl:fix-2533-tomcat-fixed-in
Open

nikolya-ctrl wants to merge 2 commits into
aboutcode-org:mainfrom
nikolya-ctrl:fix-2533-tomcat-fixed-in

Conversation

@nikolya-ctrl

Copy link
Copy Markdown

Fixes #2533

Problem

parse_tomcat_security extracted the fixed version with Tomcat\s+([\d\.]+), which only matches digits and dots. Milestone/pre-release fixed versions were truncated at the -, e.g. "Fixed in Apache Tomcat 11.0.0-M6" was parsed as 11.0.0. On https://tomcat.apache.org/security-11.html this affects 7 headings (11.0.0-M3 through M21), which all collapsed to 11.0.0.

Fix

Allow an optional -<suffix> after the numeric part: Tomcat\s+([\d\.]+(?:-[A-Za-z0-9]+)?). Normal versions like 10.1.9 are unchanged.

Tests

Added test_parse_tomcat_security_keeps_milestone_fixed_version. All 5 tests in test_apache_tomcat_importer_pipeline.py pass locally (Python 3.13, WSL Ubuntu); the existing tests already cover plain versions like 10.1.9 and 9.0.76.

Before / after (reproduction script from #2533)

Before: fixed_in: 11.0.0
After: fixed_in: 11.0.0-M6

Note

This is independent of #2531 (which fixes the "Affects" parsing for #2528). Both touch apache_tomcat_importer.py but different functions, so they can be merged in either order.


I found and reported this bug, reproduced it, implemented the fix with a test, 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.

parse_tomcat_security matched only digits and dots, so 'Fixed in Apache Tomcat 11.0.0-M6' was parsed as 11.0.0. Allow an optional -<suffix> (e.g. -M6, -RC1) in the regex. Add a test. Fixes aboutcode-org#2533

Signed-off-by: Nikolya Fernando <238961989+nikolya-ctrl@users.noreply.github.com>
@Jean-Regis-M

Copy link
Copy Markdown

Checked together with #2531: with both changes, Affects: 11.0.0-M5 and Fixed in ... 11.0.0-M6 give vers:apache/11.0.0-M5|!=11.0.0-M6. The code merges cleanly; only the test files conflict (both append after the last test), so whichever lands second needs a small rebase.

Tomcat 9 headings use 9.0.0.M22 rather than 9.0.0-M22, which the previous regex truncated to '9.0.0.'. Match numeric parts separately and allow a '.' or '-' before the suffix. Add a test.

Signed-off-by: Nikolya Fernando <238961989+nikolya-ctrl@users.noreply.github.com>
@nikolya-ctrl

Copy link
Copy Markdown
Author

Small follow-up: while checking https://tomcat.apache.org/security-9.html I noticed Tomcat 9 writes milestones with a dot (e.g. "Fixed in Apache Tomcat 9.0.0.M22"), and some older entries use a dash. The previous regex truncated the dot style to 9.0.0..

I updated the regex to Tomcat\s+(\d+(?:\.\d+)*(?:[.-][A-Za-z]+\d*)?) so it handles 9.0.0.M22, 11.0.0-M6, 8.0.0-RC1 and plain versions like 10.1.9, and added test_parse_tomcat_security_keeps_dot_style_milestone_fixed_version. All 6 tests in test_apache_tomcat_importer_pipeline.py pass.

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.

ApacheTomcatImporterPipeline truncates milestone fixed versions (e.g. 11.0.0-M6 -> 11.0.0)

2 participants