Skip to content

Commit da69ef9

Browse files
committed
fix: update pcre2 pattern for android
Add support for detecting pcre2 versions in Android binaries which use null byte separators instead of newlines. Each Android API version has different string layouts requiring separate patterns. Tested on Android APIs 28, 29, 30, and 34. Signed-off-by: Jack <72348727+Jack-GitHub12@users.noreply.github.com>
1 parent 53d5549 commit da69ef9

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

cve_bin_tool/checkers/pcre2.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ class Pcre2Checker(Checker):
1717
CONTAINS_PATTERNS: list[str] = []
1818
FILENAME_PATTERNS: list[str] = [r"pcre2"]
1919
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",
20+
r"BSR_UNICODE\)[\x00\r\n]+([0-9]+\.[0-9]+)",
21+
r"DEFINE[\x00\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}[\x00\r\n]+BSR_ANYCRLF",
23+
r"Unicode not supported[\x00\r\n]+([0-9]+\.[0-9]+) [0-9]{4}-[0-9]{2}-[0-9]{2}",
24+
r"BSR_ANYCRLF\)[\x00\r\n]+([0-9]+\.[0-9]+) [0-9]{4}-[0-9]{2}-[0-9]{2}",
25+
r"NOTEMPTY_ATSTART\)[\x00\r\n]+([0-9]+\.[0-9]+) [0-9]{4}-[0-9]{2}-[0-9]{2}",
2326
]
2427
VENDOR_PRODUCT = [("pcre", "pcre2")]

test/test_data/pcre2.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
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+
{
6+
"product": "pcre2",
7+
"version": "10.22",
8+
"version_strings": ["BSR_UNICODE)\n10.22"],
9+
},
610
{
711
"product": "pcre2",
812
"version": "10.33",
@@ -13,6 +17,26 @@
1317
"version": "10.40",
1418
"version_strings": ["10.40 2022-04-14\nBSR_ANYCRLF"],
1519
},
20+
{
21+
"product": "pcre2",
22+
"version": "10.22",
23+
"version_strings": ["Unicode not supported\x0010.22 2016-07-29"],
24+
},
25+
{
26+
"product": "pcre2",
27+
"version": "10.32",
28+
"version_strings": ["BSR_ANYCRLF)\x0010.32 2018-09-10"],
29+
},
30+
{
31+
"product": "pcre2",
32+
"version": "10.33",
33+
"version_strings": ["DEFINE\x0010.33 2019-04-16"],
34+
},
35+
{
36+
"product": "pcre2",
37+
"version": "10.40",
38+
"version_strings": ["NOTEMPTY_ATSTART)\x0010.40 2022-04-14"],
39+
},
1640
]
1741
package_test_data = [
1842
{

0 commit comments

Comments
 (0)