From 490e05adb20744ab3d71b745046a9cf65d454952 Mon Sep 17 00:00:00 2001 From: witchcraze <67056980+witchcraze@users.noreply.github.com> Date: Mon, 29 Jul 2024 22:46:51 +0900 Subject: [PATCH] fix: traefik classifier (#3077) Signed-off-by: witchcraze --- .../pkg/cataloger/binary/classifier_cataloger_test.go | 11 +++++++++++ syft/pkg/cataloger/binary/classifiers.go | 3 ++- syft/pkg/cataloger/binary/test-fixtures/config.yaml | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index 978e45755..9876df496 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -204,6 +204,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("traefik-binary"), }, }, + { + logicalFixture: "traefik/3.0.4/linux-riscv64", + expected: pkg.Package{ + Name: "traefik", + Version: "3.0.4", + Type: "binary", + PURL: "pkg:generic/traefik@3.0.4", + Locations: locations("traefik"), + Metadata: metadata("traefik-binary"), + }, + }, { logicalFixture: "memcached/1.6.18/linux-amd64", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index e11cd2a7f..e2797b047 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -263,7 +263,8 @@ func DefaultClassifiers() []Classifier { EvidenceMatcher: FileContentsVersionMatcher( // [NUL]v1.7.34[NUL] // [NUL]2.9.6[NUL] - `(?m)(\x00|\x{FFFD})v?(?P[0-9]+\.[0-9]+\.[0-9]+(-alpha[0-9]|-beta[0-9]|-rc[0-9])?)\x00`), + // 3.0.4[NUL] + `(?m)(\x00|\x{FFFD})?v?(?P[0-9]+\.[0-9]+\.[0-9]+(-alpha[0-9]|-beta[0-9]|-rc[0-9])?)\x00`), Package: "traefik", PURL: mustPURL("pkg:generic/traefik@version"), CPEs: singleCPE("cpe:2.3:a:traefik:traefik:*:*:*:*:*:*:*:*"), diff --git a/syft/pkg/cataloger/binary/test-fixtures/config.yaml b/syft/pkg/cataloger/binary/test-fixtures/config.yaml index e14c050c5..b00fd2103 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/config.yaml +++ b/syft/pkg/cataloger/binary/test-fixtures/config.yaml @@ -448,6 +448,12 @@ from-images: paths: - /usr/local/bin/traefik + - version: 3.0.4 + images: + - ref: traefik:3.0.4@sha256:12a7cc4232b5b7fe027673da8c096144525f59a8eabc87e52260aac0ec5a1219 + platform: linux/riscv64 + paths: + - /usr/local/bin/traefik # from the original dynamic fixtures...