Skip to content

Keep milestone suffix in Tomcat fixed versions - #2534

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

nikolya-ctrl wants to merge 3 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.

@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.

Works on the real pages. I saved security-7 to security-11 today and ran collect_advisories() on them, on 9a9c9b3 and on this branch.

Both import the same number of advisories. 104 version ranges change, all on the 8–11 pages. Example, CVE-2017-7675:

base : vers:maven/>=9.0.0.M1|<=9.0.0.M21|!=9.0.0.
here : vers:maven/>=9.0.0.M1|<=9.0.0.M21|!=9.0.0.M22

One thing you'll still see in the output, already tracked in #2528 (not caused by this PR). Affects: 11.0.0-M5 is split on the hyphen:

apache : vers:apache/!=11.0.0-M6|>=11.0.0     (11.0.9 in range: True, 11.0.0-M5: False)
maven  : vers:maven/<=M5|!=11.0.0-M6|>=11.0.0

For whoever picks that up: I counted three such lines (8.0.0-RC1, 11.0.0-M1, 11.0.0-M5), while security-7 has many real ranges written as 7.0.0-7.0.53. So the hyphen split can't simply be removed.

@nikolya-ctrl

nikolya-ctrl commented Dec 1, 2026 •

Copy link
Copy Markdown
Author

Thanks for testing this on the real pages, @Jean-Regis-M! Really nice to see that 104 ranges improved and the number of advisories stayed the same.

The 11.0.0-M5 split you mentioned is fixed in #2531. I applied both PRs together and ran them on security-7 to security-11:

  • 8.0.0-RC1 gives vers:apache/8.0.0-RC1|!=8.0.0-RC3
  • 11.0.0-M1 gives vers:apache/11.0.0-M1|!=11.0.0-M3
  • 11.0.0-M5 gives vers:apache/11.0.0-M5|!=11.0.0-M6

All 29 real ranges on security-7 (like 7.0.0-7.0.53) still split normally into >=/<=, because #2531 only treats the value as a single version when the part after the last - starts with a letter.

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