Skip to content

Commit

Permalink
fix: split curl and libcurl checkers
Browse files Browse the repository at this point in the history
Fix intel#3173

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
  • Loading branch information
ffontaine committed Aug 11, 2023
1 parent df822cf commit ac1fb00
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 23 deletions.
1 change: 1 addition & 0 deletions cve_bin_tool/checkers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"libass",
"libbpg",
"libconfuse",
"libcurl",
"libdb",
"libebml",
"libgcrypt",
Expand Down
4 changes: 2 additions & 2 deletions cve_bin_tool/checkers/curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ class CurlChecker(Checker):
# r"ignoring --proxy-capath, not supported by libcurl",
]
FILENAME_PATTERNS = [r"curl"]
VERSION_PATTERNS = [r"curl[ -/]([678]+\.[0-9]+\.[0-9]+)"]
VENDOR_PRODUCT = [("haxx", "curl"), ("haxx", "libcurl")]
VERSION_PATTERNS = [r"\r?\ncurl[ -/]([678]+\.[0-9]+\.[0-9]+)"]
VENDOR_PRODUCT = [("haxx", "curl")]
20 changes: 20 additions & 0 deletions cve_bin_tool/checkers/libcurl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2023 Orange
# SPDX-License-Identifier: GPL-3.0-or-later


"""
CVE checker for libcurl:
https://www.cvedetails.com/product/25085/Haxx-Libcurl.html?vendor_id=12682
"""
from __future__ import annotations

from cve_bin_tool.checkers import Checker


class LibcurlChecker(Checker):
CONTAINS_PATTERNS: list[str] = []
FILENAME_PATTERNS: list[str] = []
VERSION_PATTERNS = [r"libcurl[ -/]([678]+\.[0-9]+\.[0-9]+)"]
VENDOR_PRODUCT = [("haxx", "libcurl")]
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion test/config/cve_bin_tool_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ input_file = "test/csv/triage.csv"
skips = ["python", "bzip2"]

# list of checkers you want to run
runs = ["curl", "binutils"]
runs = ["libcurl", "binutils"]

[output]

Expand Down
2 changes: 1 addition & 1 deletion test/config/cve_bin_tool_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ checker:
- bzip2
# list of checkers you want to run
runs:
- curl
- libcurl
- binutils

output:
Expand Down
8 changes: 4 additions & 4 deletions test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,18 +324,18 @@ def test_config_file(self, caplog, filename):
# scan with config file and overwrite output format
assert main(["cve-bin-tool", "-C", filename, "-l", "info"]) != 0

# assert only checkers for binutils and curl get to run
# assert only checkers for binutils and libcurl get to run
assert (
"cve_bin_tool.VersionScanner",
logging.INFO,
"Checkers: binutils, curl",
"Checkers: binutils, libcurl",
) in caplog.record_tuples

# assert only CVEs of curl and libcurl get reflected. Because others are skipped
# assert only CVEs of libcurl get reflected. Because others are skipped
assert (
"cve_bin_tool",
logging.INFO,
"There are 2 products with known CVEs detected",
"There are 1 products with known CVEs detected",
) in caplog.record_tuples

for record in caplog.record_tuples:
Expand Down
2 changes: 1 addition & 1 deletion test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestConfig:
"log_level": "debug",
"output_file": "",
"quiet": False,
"runs": ["curl", "binutils"],
"runs": ["libcurl", "binutils"],
"severity": "low",
"skips": ["python", "bzip2"],
"update": "daily",
Expand Down
18 changes: 4 additions & 14 deletions test/test_data/curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"package_name": "curl-7.32.0-3.fc20.x86_64.rpm",
"product": "curl",
"version": "7.32.0",
"other_products": ["libcurl"],
},
{
"url": "https://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/aarch64/9.1/All/",
Expand All @@ -26,20 +25,11 @@
"package_name": "curl_7.52.1-5+deb9u10_amd64.deb",
"product": "curl",
"version": "7.52.1",
"other_products": ["libcurl"],
},
{
"url": "http://mirror.centos.org/centos/7/os/x86_64/Packages/",
"package_name": "libcurl-7.29.0-59.el7.x86_64.rpm",
"product": "libcurl",
"version": "7.29.0",
"other_products": ["curl"],
},
{
"url": "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/30/Everything/x86_64/os/Packages/l/",
"package_name": "libcurl-7.64.0-6.fc30.x86_64.rpm",
"product": "libcurl",
"version": "7.64.0",
"other_products": ["curl"],
"url": "https://downloads.openwrt.org/releases/packages-19.07/x86_64/base/",
"package_name": "curl_7.66.0-3_x86_64.ipk",
"product": "curl",
"version": "7.66.0",
},
]
34 changes: 34 additions & 0 deletions test/test_data/libcurl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (C) 2023 Orange
# SPDX-License-Identifier: GPL-3.0-or-later

mapping_test_data = [
{"product": "libcurl", "version": "7.34.0", "version_strings": ["libcurl 7.34.0"]},
{"product": "libcurl", "version": "7.34.0", "version_strings": ["libcurl-7.34.0"]},
{"product": "libcurl", "version": "7.34.0", "version_strings": ["libcurl/7.34.0"]},
]
package_test_data = [
{
"url": "http://ftp.br.debian.org/debian/pool/main/c/curl/",
"package_name": "libcurl3-gnutls_7.64.0-4+deb10u2_amd64.deb",
"product": "libcurl",
"version": "7.64.0",
},
{
"url": "http://mirror.centos.org/centos/7/os/x86_64/Packages/",
"package_name": "libcurl-7.29.0-59.el7.x86_64.rpm",
"product": "libcurl",
"version": "7.29.0",
},
{
"url": "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/30/Everything/x86_64/os/Packages/l/",
"package_name": "libcurl-7.64.0-6.fc30.x86_64.rpm",
"product": "libcurl",
"version": "7.64.0",
},
{
"url": "https://downloads.openwrt.org/releases/packages-19.07/x86_64/base/",
"package_name": "libcurl4_7.66.0-3_x86_64.ipk",
"product": "libcurl",
"version": "7.66.0",
},
]

0 comments on commit ac1fb00

Please sign in to comment.