From e61aac0b5332d90ac47accc878860341a6e4fc64 Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Wed, 10 Jan 2024 10:50:38 -0500 Subject: [PATCH] feat: binary classifier for GCC (#2479) Signed-off-by: Laurent Goderre --- syft/pkg/cataloger/binary/cataloger_test.go | 11 +++++++++++ syft/pkg/cataloger/binary/default_classifiers.go | 11 +++++++++++ .../snippets/gcc/12.3.0/linux-amd64/gcc | Bin 0 -> 347 bytes .../cataloger/binary/test-fixtures/config.yaml | 7 +++++++ 4 files changed, 29 insertions(+) create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/gcc/12.3.0/linux-amd64/gcc 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 0000000000000000000000000000000000000000..98428d1c3a3391594f38561353328ed7b9223679 GIT binary patch literal 347 zcmXw!u};J=42CmjXODCX3`9wjCcSQO!|4_l-~pV(Zcpm9RU3rLQ`{pH4zOhXvOn4W zJ;DWB(Z$Foq7`#1w6Ug9mJc{~xi594_&T2F8S`roRqa|4KsoJ`tD*6ZoU_SbnQ~q$ z?KSLElN#r1aC@sG?DnJnS8$ z%GLl?xoj&iL7S4nk&m43b~_QajN;Fx$djOH7^Y8A5N9Q>UvEFcu6L)K9uJ3B+#g@w zAIg8yNX3|3`!z2a0+Z)4<1#ZjP8nr4e#m*5W?b_2*Lr$BJ!a_GjrFkhOr~vIx67~Q H