From a3438256856d372d94a8f13c651dded916e5c56d Mon Sep 17 00:00:00 2001 From: witchcraze <67056980+witchcraze@users.noreply.github.com> Date: Fri, 6 Sep 2024 03:52:19 +0900 Subject: [PATCH] fix: haproxy classifier for versions with -dev suffix (#3180) Signed-off-by: witchcraze --- .../cataloger/binary/classifier_cataloger_test.go | 12 +++++++++++- syft/pkg/cataloger/binary/classifiers.go | 4 ++-- .../snippets/haproxy/3.1-dev0/linux-amd64/haproxy | Bin 0 -> 351 bytes .../cataloger/binary/test-fixtures/config.yaml | 7 +++++++ 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/haproxy/3.1-dev0/linux-amd64/haproxy diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index 721ee9ee045..4e283a56a1e 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -359,7 +359,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("haproxy-binary"), }, }, - + { + logicalFixture: "haproxy/3.1-dev0/linux-amd64", + expected: pkg.Package{ + Name: "haproxy", + Version: "3.1-dev0", + Type: "binary", + PURL: "pkg:generic/haproxy@3.1-dev0", + Locations: locations("haproxy"), + Metadata: metadata("haproxy-binary"), + }, + }, { logicalFixture: "helm/3.11.1/linux-amd64", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index 24c514c7e45..46afa87f5cb 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -190,8 +190,8 @@ func DefaultClassifiers() []Classifier { Class: "haproxy-binary", FileGlob: "**/haproxy", EvidenceMatcher: evidenceMatchers( - FileContentsVersionMatcher(`(?m)HA-Proxy version (?P[0-9]+\.[0-9]+\.[0-9]+)`), - FileContentsVersionMatcher(`(?m)(?P[0-9]+\.[0-9]+\.[0-9]+)-[0-9a-zA-Z]{7}.+HAProxy version`), + FileContentsVersionMatcher(`(?m)HA-Proxy version (?P[0-9]+\.[0-9]+(\.|-dev)[0-9]+)`), + FileContentsVersionMatcher(`(?m)(?P[0-9]+\.[0-9]+(\.|-dev)[0-9]+)-[0-9a-zA-Z]{7}.+HAProxy version`), ), Package: "haproxy", PURL: mustPURL("pkg:generic/haproxy@version"), diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/haproxy/3.1-dev0/linux-amd64/haproxy b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/haproxy/3.1-dev0/linux-amd64/haproxy new file mode 100644 index 0000000000000000000000000000000000000000..94a91b1ad84b87e6746984d2de620782f99345f9 GIT binary patch literal 351 zcmYLFF>b>!49u*lPY~cajYL_pk{mJu6iv*js$YUSERIq;50;z)4x zXKH!pr%V32v7FLOOUspZt~QnpG`=rg%OwalkNq^!^459Krbt@YfDxQ87_88goYXGX zg^CE|Qez@wsDnl!Aw^Q?h>R5x!AM}KAL!2vl~dLhKZ8od;G0Hj>71g7$|q$!MQ<>g z;whV;oDK%d=0=7HR?C{Ps;W5N7UKJve91iJVaT7nv>3R<0R+@1p-(GcLp{o4q^mee qLXiMA^*_HnzphW=SGvr79(TL>aQ~=(hrV~bKj^LAk)OBzQ^6mkZdh&r literal 0 HcmV?d00001 diff --git a/syft/pkg/cataloger/binary/test-fixtures/config.yaml b/syft/pkg/cataloger/binary/test-fixtures/config.yaml index 15273d33d2f..78d8ba4b8cf 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/config.yaml +++ b/syft/pkg/cataloger/binary/test-fixtures/config.yaml @@ -106,6 +106,13 @@ from-images: paths: - /usr/local/sbin/haproxy + - version: 3.1-dev0 + images: + - ref: haproxy:3.1-dev0@sha256:eba1aac9aa6ea84869bd2ecae79792a934563fd731eddf724eb3b12ef6a9b93f + platform: linux/amd64 + paths: + - /usr/local/sbin/haproxy + - version: 2.4.54 images: - ref: httpd:2.4.54@sha256:c13feaef62bdb03e65e645f47d9780adea5a080c78eb9e4b3c32e861327262b4