Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve dhclient checker and add dhcpd checker #2642

Merged
merged 1 commit into from
Feb 8, 2023
Merged
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
1 change: 1 addition & 0 deletions cve_bin_tool/checkers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"dbus",
"dhclient",
"dhcpcd",
"dhcpd",
"dnsmasq",
"domoticz",
"dovecot",
Expand Down
11 changes: 5 additions & 6 deletions cve_bin_tool/checkers/dhclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@


"""
CVE checker for dhcp-client

This checker only supports .rpm distros as no useful version patterns were found for .deb
CVE checker for dhcp-client (ISC DHCP client)

https://www.cvedetails.com/product/610/ISC-Dhcp-Client.html?vendor_id=64
https://www.cvedetails.com/product/17706/ISC-Dhcp.html?vendor_id=64

"""
from __future__ import annotations
Expand All @@ -19,7 +18,7 @@ class DhclientChecker(Checker):
CONTAINS_PATTERNS: list[str] = []
FILENAME_PATTERNS: list[str] = [r"dhclient"]
VERSION_PATTERNS = [
r'"name":"dhcp","version":"([0-9]+.[0-9]+(.[0-9]+)?)',
r"dhcp([0-9]+.[0-9]+(.[0-9]+)?)",
r"dhclient\.c[a-zA-Z0-9 \'%-\[\]{}<>#%|\.:\r\n]*([0-9]+\.[0-9]+\.[0-9]+)",
r"([0-9]+\.[0-9]+\.[0-9]+)[a-zA-Z0-9 \'%-\[\]{}<>#%|\.:\r\n]*dhclient\.c",
]
VENDOR_PRODUCT = [("isc", "dhcp")]
VENDOR_PRODUCT = [("isc", "dhcp"), ("isc", "dhcp_client")]
24 changes: 24 additions & 0 deletions cve_bin_tool/checkers/dhcpd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2023 Orange
# SPDX-License-Identifier: GPL-3.0-or-later


"""
CVE checker for dhcpd (ISC DHCP server)

https://www.cvedetails.com/product/2017/ISC-Dhcpd.html?vendor_id=64
https://www.cvedetails.com/product/17706/ISC-Dhcp.html?vendor_id=64

"""
from __future__ import annotations

from cve_bin_tool.checkers import Checker


class DhcpdChecker(Checker):
CONTAINS_PATTERNS: list[str] = []
FILENAME_PATTERNS: list[str] = []
VERSION_PATTERNS = [
r"\r?\ndhcpd\.c[a-zA-Z0-9 \'%-\[\]{}<>#%|\.:\r\n]*([0-9]+\.[0-9]+\.[0-9]+)",
r"([0-9]+\.[0-9]+\.[0-9]+)[a-zA-Z0-9 \'%-\[\]{}<>#%|\.:\r\n]*dhcpd\.c\r?\n",
]
VENDOR_PRODUCT = [("isc", "dhcp"), ("isc", "dhcpd")]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 16 additions & 7 deletions test/test_data/dhclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
# SPDX-License-Identifier: GPL-3.0-or-later

mapping_test_data = [
{
"product": "dhcp",
"version": "4.4.3",
"version_strings": [r'"name":"dhcp","version":"4.4.3"'],
},
{"product": "dhcp", "version": "4.3.1", "version_strings": ["dhclient.c\n4.3.1"]},
{"product": "dhcp", "version": "4.4.3", "version_strings": ["4.4.3\ndhclient.c"]},
]
package_test_data = [
{
Expand All @@ -16,6 +13,18 @@
"version": "4.4.3",
"other_products": [],
},
{
"url": "http://ftp.fr.debian.org/debian/pool/main/i/isc-dhcp/",
"package_name": "isc-dhcp-client_4.3.1-6+deb8u3_amd64.deb",
"product": "dhcp",
"version": "4.3.1",
"other_products": [],
},
{
"url": "https://downloads.openwrt.org/releases/packages-19.07/x86_64/packages/",
"package_name": "isc-dhcp-client-ipv4_4.4.1-4_x86_64.ipk",
"product": "dhcp",
"version": "4.4.1",
"other_products": [],
},
]

# This checker only supports .rpm distros as no useful version patterns were found for .deb
34 changes: 34 additions & 0 deletions test/test_data/dhcpd.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": "dhcpd", "version": "4.3.5", "version_strings": ["4.3.5\ndhcpd.c"]},
{
"product": "dhcpd",
"version": "4.4.3",
"version_strings": ["dhcpd.c\nCan't allocate new generic object: %s\n4.4.3"],
},
]
package_test_data = [
{
"url": "https://www.rpmfind.net/linux/fedora/linux/development/rawhide/Everything/aarch64/os/Packages/d/",
"package_name": "dhcp-server-4.4.3-7.P1.fc38.aarch64.rpm",
"product": "dhcpd",
"version": "4.4.3",
"other_products": ["dhcp"],
},
{
"url": "http://ftp.fr.debian.org/debian/pool/main/i/isc-dhcp/",
"package_name": "isc-dhcp-server_4.3.5-3+deb9u1_arm64.deb",
"product": "dhcpd",
"version": "4.3.5",
"other_products": ["dhcp"],
},
{
"url": "https://downloads.openwrt.org/releases/packages-19.07/x86_64/packages/",
"package_name": "isc-dhcp-server-ipv6_4.4.1-4_x86_64.ipk",
"product": "dhcpd",
"version": "4.4.1",
"other_products": ["dhcp"],
},
]