Skip to content

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

Backlog

Description

@nikolya-ctrl

parse_tomcat_security in vulnerabilities/pipelines/v2_importers/apache_tomcat_importer.py extracts the fixed version from headings like "Fixed in Apache Tomcat 11.0.0-M6" with:

re.search(r"Tomcat\s+([\d\.]+)", header.get_text())

[\d\.]+ only matches digits and dots, so it stops at the - and milestone/pre-release fixed versions are truncated: 11.0.0-M6 becomes 11.0.0.

Reproduction

import django
django.setup()

from vulnerabilities.pipelines.v2_importers.apache_tomcat_importer import parse_tomcat_security

HTML = """
<h3 id="Fixed_in_Apache_Tomcat_11.0.0-M6">Fixed in Apache Tomcat 11.0.0-M6</h3>
<div class="text">
<p><strong>Important: Information disclosure</strong>
<a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-34981">CVE-2023-34981</a></p>
<p>Affects: 11.0.0-M5</p>
</div>
"""

for advisory in parse_tomcat_security(HTML):
    print("fixed_in:", advisory.fixed_in)

Run with PYTHONPATH=. DJANGO_SETTINGS_MODULE=vulnerablecode.settings python repro.py on current main.

Actual: fixed_in: 11.0.0
Expected: fixed_in: 11.0.0-M6

Impact

On https://tomcat.apache.org/security-11.html, 7 "Fixed in" headings use milestone versions (11.0.0-M3, M5, M6, M11, M12, M17, M21). All of them collapse to 11.0.0, which is also a real release heading on the same page. So these advisories get the wrong fixed version, and the fixed-version constraint ends up as !=11.0.0 instead of !=11.0.0-M6.

I noticed this while working on #2528 (PR #2531). I'd like to work on a fix with tests if that's okay.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions