diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index 2d6b7a4ea..f2e4fe207 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -699,6 +699,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("go-binary-hint"), }, }, + { + // note: this is for compatability with dev version of golang tip image, which resolves the issue #3681 + logicalFixture: "go-version-hint/1.25/any", + expected: pkg.Package{ + Name: "go", + Version: "1.25-d524e1e", + PURL: "pkg:generic/go@1.25-d524e1e", + Locations: locations("VERSION.cache"), + Metadata: metadata("go-binary-hint"), + }, + }, { // note: this is testing BUSYBOX which is typically through a link to "[" (in this case a symlink but in // practice this is often a hard link). diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index f0fff7a85..dc3ff40f3 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -171,9 +171,9 @@ func DefaultClassifiers() []Classifier { }, { Class: "go-binary-hint", - FileGlob: "**/VERSION", + FileGlob: "**/VERSION*", EvidenceMatcher: FileContentsVersionMatcher( - `(?m)go(?P[0-9]+\.[0-9]+(\.[0-9]+|beta[0-9]+|alpha[0-9]+|rc[0-9]+)?)`), + `(?m)go(?P[0-9]+\.[0-9]+(\.[0-9]+|beta[0-9]+|alpha[0-9]+|rc[0-9]+)?(-[0-9a-f]{7})?)`), Package: "go", PURL: mustPURL("pkg:generic/go@version"), CPEs: singleCPE("cpe:2.3:a:golang:go:*:*:*:*:*:*:*:*", cpe.NVDDictionaryLookupSource), diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/go-version-hint/1.25/any/VERSION.cache b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/go-version-hint/1.25/any/VERSION.cache new file mode 100644 index 000000000..5ac1e7aad --- /dev/null +++ b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/go-version-hint/1.25/any/VERSION.cache @@ -0,0 +1,2 @@ +devel go1.25-d524e1e Sun Feb 16 07:23:13 2025 -0800 +3devel go1.25-d524e1e Sun Feb 16 07:23:13 2025 -0800 \ No newline at end of file diff --git a/syft/pkg/cataloger/binary/test-fixtures/config.yaml b/syft/pkg/cataloger/binary/test-fixtures/config.yaml index f421cdfd3..b4a3bcc71 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/config.yaml +++ b/syft/pkg/cataloger/binary/test-fixtures/config.yaml @@ -130,6 +130,12 @@ from-images: paths: - /usr/local/go/bin/go + - version: 1.25 + images: + - ref: golang:tip@sha256:319b219d4df413ef30123a7f69bdf00032d9841af58d7b0ef6971542b29875d5 + platform: linux/amd64 + paths: + - /usr/local/go/bin/go # TODO: this is no longer available from dockerhub! (the snippet is vital) - version: 1.5.14 images: