From 32b5e189ba409a3278024f4321583e4acc25bc68 Mon Sep 17 00:00:00 2001 From: Wasaf Abbasi <95940455+Abbasi26@users.noreply.github.com> Date: Tue, 3 Nov 2026 11:57:08 +0100 Subject: [PATCH] =?UTF-8?q?F=C3=BCnf=20CPE-Aliase=20f=C3=BCr=20g=C3=A4ngig?= =?UTF-8?q?e=20Produkte=20zur=20Starter-Tabelle=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automatisch erstellt von OpenClaw (Modell: kilo/kilo-auto/free). --- src/patchorder/aliases.py | 5 +++++ tests/test_resolver.py | 47 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/patchorder/aliases.py b/src/patchorder/aliases.py index 53eb390..4d107af 100644 --- a/src/patchorder/aliases.py +++ b/src/patchorder/aliases.py @@ -89,6 +89,11 @@ def _cpe(alias: Alias) -> str: Alias(("windows 10 1809",), ("microsoft",), "o", "microsoft", "windows_10_1809", "Windows 10 1809 (build family 17763)."), Alias(("windows 10 1607",), ("microsoft",), "o", "microsoft", "windows_10_1607", "Windows 10 1607 (build family 14393)."), Alias(("windows 10 1507",), ("microsoft",), "o", "microsoft", "windows_10_1507", "Windows 10 1507 (build family 10240)."), + Alias(("redis",), ("redis",), "a", "redis", "redis", "Redis upstream CPE."), + Alias(("haproxy",), ("haproxy",), "a", "haproxy", "haproxy", "HAProxy from HAProxy Technologies."), + Alias(("varnish",), ("varnish",), "a", "varnish", "varnish", "Varnish Cache upstream CPE."), + Alias(("bind 9", "bind9"), ("isc",), "a", "isc", "bind9", "BIND 9 from ISC, not Microsoft DNS or Unbound."), + Alias(("node.js", "nodejs"), ("nodejs", "node"), "a", "nodejs", "node.js", "Node.js runtime; the CPE vendor is nodejs."), ) # When the primary alias hits, also show this other dictionary name, lower. diff --git a/tests/test_resolver.py b/tests/test_resolver.py index 6ea4e8a..f92d563 100644 --- a/tests/test_resolver.py +++ b/tests/test_resolver.py @@ -86,3 +86,50 @@ def test_dictionary_hit_merges_with_alias(): top = resolution.candidates[0] assert top.cpe == "cpe:2.3:a:f5:nginx" assert top.confidence >= 0.93 + + +def test_redis_alias_resolves_to_redis_cpe(): + resolution = resolve_asset(_asset(product="Redis", vendor="Redis", version="7.2.4")) + assert resolution.chosen is not None + assert resolution.chosen.cpe == "cpe:2.3:a:redis:redis" + assert resolution.chosen.confidence >= AUTO_USE_CONFIDENCE + + +def test_haproxy_alias_resolves_to_haproxy_cpe(): + resolution = resolve_asset(_asset(product="HAProxy", vendor="HAProxy Technologies", version="2.8.5")) + assert resolution.chosen is not None + assert resolution.chosen.cpe == "cpe:2.3:a:haproxy:haproxy" + assert resolution.chosen.confidence >= AUTO_USE_CONFIDENCE + + +def test_varnish_alias_resolves_to_varnish_cpe(): + resolution = resolve_asset(_asset(product="Varnish Cache", vendor="Varnish", version="7.6.0")) + assert resolution.chosen is not None + assert resolution.chosen.cpe == "cpe:2.3:a:varnish:varnish" + assert resolution.chosen.confidence >= AUTO_USE_CONFIDENCE + + +def test_bind9_alias_resolves_to_isc_bind9_cpe(): + resolution = resolve_asset(_asset(product="BIND 9", vendor="ISC", version="9.18.24")) + assert resolution.chosen is not None + assert resolution.chosen.cpe == "cpe:2.3:a:isc:bind9" + assert resolution.chosen.confidence >= AUTO_USE_CONFIDENCE + + +def test_nodejs_alias_resolves_to_nodejs_cpe(): + resolution = resolve_asset(_asset(product="Node.js", vendor="Node.js", version="20.11.1")) + assert resolution.chosen is not None + assert resolution.chosen.cpe == "cpe:2.3:a:nodejs:node.js" + assert resolution.chosen.confidence >= AUTO_USE_CONFIDENCE + + +def test_new_aliases_do_not_add_alternate_entries(): + from patchorder.aliases import ALTERNATES + for cpe in ( + "cpe:2.3:a:redis:redis", + "cpe:2.3:a:haproxy:haproxy", + "cpe:2.3:a:varnish:varnish", + "cpe:2.3:a:isc:bind9", + "cpe:2.3:a:nodejs:node.js", + ): + assert cpe not in ALTERNATES