Skip to content

Commit 5b7535d

Browse files
committed
fix: update pcre2 pattern for android (#5441)
Add pattern to detect libpcre2 version in Android libraries where the version string format differs from standard Linux binaries. - Add FILENAME_PATTERNS to match pcre2 library files - Add VERSION_PATTERNS for Android format with version+date and "this version of PCRE2" error message as anchor - Add test case for Android libpcre2 format
1 parent b605e46 commit 5b7535d

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

cve_bin_tool/checkers/pcre2.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
class Pcre2Checker(Checker):
1717
CONTAINS_PATTERNS: list[str] = []
18-
FILENAME_PATTERNS: list[str] = []
19-
VERSION_PATTERNS = [r"BSR_UNICODE\)\r?\n([0-9]+\.[0-9]+)"]
18+
FILENAME_PATTERNS: list[str] = [r"pcre2"]
19+
VERSION_PATTERNS = [
20+
r"BSR_UNICODE\)\r?\n([0-9]+\.[0-9]+)",
21+
r"DEFINE\r?\n([0-9]+\.[0-9]+) [0-9]{4}-[0-9]{2}-[0-9]{2}",
22+
r"([0-9]+\.[0-9]+) [0-9]{4}-[0-9]{2}-[0-9]{2}\r?\nBSR_ANYCRLF",
23+
]
2024
VENDOR_PRODUCT = [("pcre", "pcre2")]

test/test_data/pcre2.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22
# SPDX-License-Identifier: GPL-3.0-or-later
33

44
mapping_test_data = [
5-
{"product": "pcre2", "version": "10.22", "version_strings": ["BSR_UNICODE)\n10.22"]}
5+
{"product": "pcre2", "version": "10.22", "version_strings": ["BSR_UNICODE)\n10.22"]},
6+
{
7+
"product": "pcre2",
8+
"version": "10.33",
9+
"version_strings": ["DEFINE\n10.33 2019-04-16"],
10+
},
11+
{
12+
"product": "pcre2",
13+
"version": "10.40",
14+
"version_strings": ["10.40 2022-04-14\nBSR_ANYCRLF"],
15+
},
616
]
717
package_test_data = [
818
{

0 commit comments

Comments
 (0)