From 263ea6b1bb7a250fb7134de5722072d3ce5b1294 Mon Sep 17 00:00:00 2001 From: witchcraze <67056980+witchcraze@users.noreply.github.com> Date: Thu, 3 Oct 2024 04:10:39 +0900 Subject: [PATCH] feat: update haproxy classifier (#3277) Signed-off-by: witchcraze --- .../cataloger/binary/classifier_cataloger_test.go | 11 +++++++++++ syft/pkg/cataloger/binary/classifiers.go | 1 + .../snippets/haproxy/2.0.0/linux-amd64/haproxy | Bin 0 -> 351 bytes .../cataloger/binary/test-fixtures/config.yaml | 7 +++++++ 4 files changed, 19 insertions(+) create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/haproxy/2.0.0/linux-amd64/haproxy diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index 4c84efb9452..1bba77b2584 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -348,6 +348,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("haproxy-binary"), }, }, + { + logicalFixture: "haproxy/2.0.0/linux-amd64", + expected: pkg.Package{ + Name: "haproxy", + Version: "2.0.0", + Type: "binary", + PURL: "pkg:generic/haproxy@2.0.0", + Locations: locations("haproxy"), + Metadata: metadata("haproxy-binary"), + }, + }, { logicalFixture: "haproxy/2.7.3/linux-amd64", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index c3e730c98fc..eb936a93a17 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -196,6 +196,7 @@ func DefaultClassifiers() []Classifier { Class: "haproxy-binary", FileGlob: "**/haproxy", EvidenceMatcher: evidenceMatchers( + FileContentsVersionMatcher(`(?m)version (?P[0-9]+\.[0-9]+(\.|-dev|-rc)[0-9]+)(-[a-z0-9]{7})?, released 20`), 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`), ), diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/haproxy/2.0.0/linux-amd64/haproxy b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/haproxy/2.0.0/linux-amd64/haproxy new file mode 100644 index 0000000000000000000000000000000000000000..12e68c56cf4b517ab6392f279ccd7d36a69b1c89 GIT binary patch literal 351 zcmYjL$!fze6wFy)@xYi|N+QYjljPs%vGgFzPl>^mjV0RTpS$mS>p}~i(+smP!JbeJ zTRTp}ZqEkqBc&RIR#+luJ%vr$&RTL7LpP3;4!2fTSc8(bp{h~Fdu1f~b{0aA5e_Sb z+#%@-D=!*Hg*RA~2HjzE`%v8*W_r)ZRs z=NFvP6uTjST=5k@fQfptky?;km^H_>z{P+1lUmHk<7nq%*uYU9>%2XN8kTun0_{d} NDS{2qg+v>g;2SmVak&5h 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 2476da49c69..22c9948c901 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/config.yaml +++ b/syft/pkg/cataloger/binary/test-fixtures/config.yaml @@ -130,6 +130,13 @@ from-images: paths: - /usr/local/sbin/haproxy + - version: 2.0.0 + images: + - ref: haproxy:2.0.0@sha256:f88bca67a2782e7bd88af168d5c11216c32104d12fe9240fac54a1d3196e3f9c + platform: linux/amd64 + paths: + - /usr/local/sbin/haproxy + - version: 2.7.3 images: - ref: haproxy:2.7.3@sha256:17d8aa6bf16882a294bdcccc757dd4002045f34b719e9f94dfd4801614801aea