Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def parse_tomcat_security(html_content):
results = []

for header in soup.find_all("h3", id=re.compile(r"Fixed_in_Apache_Tomcat")):
m = re.search(r"Tomcat\s+([\d\.]+)", header.get_text())
m = re.search(r"Tomcat\s+(\d+(?:\.\d+)*(?:[.-][A-Za-z]+\d*)?)", header.get_text())
if not m:
continue
fixed_in = m.group(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,29 @@ def test_apache_and_maven_version_ranges_created(mock_get):

for r in maven_ranges:
assert isinstance(r, MavenVersionRange)


def test_parse_tomcat_security_keeps_milestone_fixed_version():
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>
"""
advisories = parse_tomcat_security(html)
assert advisories[0].fixed_in == "11.0.0-M6"


def test_parse_tomcat_security_keeps_dot_style_milestone_fixed_version():
html = """
<h3 id="Fixed_in_Apache_Tomcat_9.0.0.M22">Fixed in Apache Tomcat 9.0.0.M22</h3>
<div class="text">
<p><strong>Low: Example</strong>
<a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-1000001">CVE-2017-1000001</a></p>
<p>Affects: 9.0.0.M1 to 9.0.0.M21</p>
</div>
"""
advisories = parse_tomcat_security(html)
assert advisories[0].fixed_in == "9.0.0.M22"