Skip to content

Commit 1cb692c

Browse files
authored
feat(checker): add mp4v2 checker (#4380)
windows_fixup must be moved to util.py to reuse this function in test_condensed_downloads.py Signed-off-by: Fabrice Fontaine <[email protected]>
1 parent 098d2b9 commit 1cb692c

File tree

7 files changed

+58
-7
lines changed

7 files changed

+58
-7
lines changed

cve_bin_tool/checkers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@
238238
"monit",
239239
"mosquitto",
240240
"motion",
241+
"mp4v2",
241242
"mpg123",
242243
"mpv",
243244
"msmtp",

cve_bin_tool/checkers/mp4v2.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (C) 2024 Orange
2+
# SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
5+
"""
6+
CVE checker for mp4v2
7+
8+
https://www.cvedetails.com/product/48319/Techsmith-Mp4v2.html?vendor_id=9035
9+
https://www.cvedetails.com/product/44070/Mp4v2-Project-Mp4v2.html?vendor_id=17731
10+
https://www.cvedetails.com/product/142097/Mp4v2-Mp4v2.html?vendor_id=30832
11+
12+
"""
13+
from __future__ import annotations
14+
15+
from cve_bin_tool.checkers import Checker
16+
17+
18+
class Mp4V2Checker(Checker):
19+
CONTAINS_PATTERNS: list[str] = []
20+
FILENAME_PATTERNS: list[str] = []
21+
VERSION_PATTERNS = [r"MP4v2\r?\nversion:\r?\n([0-9]+\.[0-9]+\.[0-9]+)"]
22+
VENDOR_PRODUCT = [
23+
("mp4v2", "mp4v2"),
24+
("mp4v2_project", "mp4v2"),
25+
("techsmith", "mp4v2"),
26+
]

cve_bin_tool/util.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,3 +609,8 @@ def decode_cpe22(cpe22) -> list:
609609
vendor, product, version = cpe[2], cpe[3], cpe[4]
610610
# Return available data, convert empty fields to None
611611
return [vendor or None, product or None, version or None]
612+
613+
614+
def windows_fixup(filename):
615+
"""Replace colon and backslash in filename to avoid a failure on Windows"""
616+
return filename.replace(":", "_").replace("\\", "_")
42.6 KB
Binary file not shown.

test/test_condensed_downloads.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import subprocess
99

1010
from cve_bin_tool.checkers import __all__ as all_test_name
11+
from cve_bin_tool.util import windows_fixup
1112

1213

1314
# Test to check condensed files are committed according to the package test data of checkers
@@ -21,7 +22,9 @@ def test_condensed_downloads():
2122
for package_test_data in package_test_data_list:
2223
for package_data in package_test_data:
2324
package_names.append(
24-
"test/condensed-downloads/" + package_data["package_name"] + ".tar.gz"
25+
"test/condensed-downloads/"
26+
+ windows_fixup(package_data["package_name"])
27+
+ ".tar.gz"
2528
)
2629

2730
condensed_downloads = subprocess.run(

test/test_data/mp4v2.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (C) 2024 Orange
2+
# SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
mapping_test_data = [
5+
{
6+
"product": "mp4v2",
7+
"version": "4.1.2",
8+
"version_strings": ["MP4v2\nversion:\n4.1.2"],
9+
}
10+
]
11+
package_test_data = [
12+
{
13+
"url": "https://eu.mirror.archlinuxarm.org/aarch64/extra/",
14+
"package_name": "libmp4v2-1:2.1.3-2-aarch64.pkg.tar.xz",
15+
"product": "mp4v2",
16+
"version": "2.1.3",
17+
"other_products": ["gcc"],
18+
},
19+
]

test/test_scanner.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
from cve_bin_tool.checkers import __all__ as all_test_name
2727
from cve_bin_tool.cvedb import CVEDB
28+
from cve_bin_tool.util import windows_fixup
2829
from cve_bin_tool.version_scanner import VersionScanner
2930

3031
# load test data
@@ -83,10 +84,6 @@ def teardown_class(cls):
8384
shutil.rmtree(cls.package_test_dir)
8485
shutil.rmtree(cls.mapping_test_dir)
8586

86-
def windows_fixup(self, filename):
87-
"""Replace colon and backslash in filename to avoid a failure on Windows"""
88-
return filename.replace(":", "_").replace("\\", "_")
89-
9087
def test_false_positive(self):
9188
self.scanner.all_cves = []
9289
with tempfile.NamedTemporaryFile(
@@ -154,7 +151,7 @@ def test_version_mapping(self, product, version, version_strings):
154151
for filename in filenames:
155152
with tempfile.NamedTemporaryFile(
156153
"w+b",
157-
suffix=self.windows_fixup(filename),
154+
suffix=windows_fixup(filename),
158155
dir=self.mapping_test_dir,
159156
delete=False,
160157
) as f:
@@ -237,7 +234,7 @@ def condensed_filepath(self, url, package_name):
237234
dirpath.mkdir()
238235
# Check if we've already made a condensed version of the file, if we
239236
# have, we're done.
240-
condensed_path = condensed_dir / (self.windows_fixup(package_name) + ".tar.gz")
237+
condensed_path = condensed_dir / (windows_fixup(package_name) + ".tar.gz")
241238
if condensed_path.is_file():
242239
return str(condensed_path)
243240
# Download the file if we don't have a condensed version of it and we

0 commit comments

Comments
 (0)