diff --git a/syft/pkg/cataloger/binary/cataloger_test.go b/syft/pkg/cataloger/binary/cataloger_test.go index 8211954be..961f2449e 100644 --- a/syft/pkg/cataloger/binary/cataloger_test.go +++ b/syft/pkg/cataloger/binary/cataloger_test.go @@ -805,6 +805,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("openssl-binary"), }, }, + { + logicalFixture: "gcc/12.3.0/linux-amd64", + expected: pkg.Package{ + Name: "gcc", + Version: "12.3.0", + Type: "binary", + PURL: "pkg:generic/gcc@12.3.0", + Locations: locations("gcc"), + Metadata: metadata("gcc-binary"), + }, + }, } for _, test := range tests { diff --git a/syft/pkg/cataloger/binary/default_classifiers.go b/syft/pkg/cataloger/binary/default_classifiers.go index 11624ad6a..39b5db5da 100644 --- a/syft/pkg/cataloger/binary/default_classifiers.go +++ b/syft/pkg/cataloger/binary/default_classifiers.go @@ -350,6 +350,17 @@ func DefaultClassifiers() []Classifier { PURL: mustPURL("pkg:generic/openssl@version"), CPEs: singleCPE("cpe:2.3:a:openssl:openssl:*:*:*:*:*:*:*:*"), }, + { + Class: "gcc-binary", + FileGlob: "**/gcc", + EvidenceMatcher: FileContentsVersionMatcher( + // GCC: \(GNU\) 12.3.0' + `GCC: \(GNU\) (?P[0-9]+\.[0-9]+\.[0-9]+)`, + ), + Package: "gcc", + PURL: mustPURL("pkg:generic/gcc@version"), + CPEs: singleCPE("cpe:2.3:a:gnu:gcc:*:*:*:*:*:*:*:*"), + }, } } diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/gcc/12.3.0/linux-amd64/gcc b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/gcc/12.3.0/linux-amd64/gcc new file mode 100644 index 000000000..98428d1c3 Binary files /dev/null and b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/gcc/12.3.0/linux-amd64/gcc differ diff --git a/syft/pkg/cataloger/binary/test-fixtures/config.yaml b/syft/pkg/cataloger/binary/test-fixtures/config.yaml index f3ab97a9a..d105857b3 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/config.yaml +++ b/syft/pkg/cataloger/binary/test-fixtures/config.yaml @@ -24,6 +24,13 @@ from-images: paths: - /usr/local/bin/bash + - version: 12.3.0 + images: + - ref: gcc:12.3.0-bookworm@sha256:2e3c00752fa23a0993b6618760bbc20263b272a0b34b2d4883159e3ebba9d8b6 + platform: linux/amd64 + paths: + - /usr/local/bin/gcc + - version: 25.3.2.6 images: - ref: erlang:25.3.2.6@sha256:0d1e530ec0e8047094f0a1d841754515bad9b0554260a3147fb34df31b3064fe