From df11561929dbc4b19e90707297df297f1358e7b1 Mon Sep 17 00:00:00 2001 From: Stijn Taelemans Date: Mon, 21 Apr 2025 22:37:15 +0200 Subject: [PATCH] Support detection of Chrome binaries (#3136) * test: add test cases Signed-off-by: Stijn Taelemans * feat: add classifier for chrome Signed-off-by: Stijn Taelemans --------- Signed-off-by: Stijn Taelemans --- .../binary/classifier_cataloger_test.go | 22 ++++++++++++++++++ syft/pkg/cataloger/binary/classifiers.go | 11 +++++++++ .../chrome/126.0.6478.182/linux-amd64/chrome | Bin 0 -> 277 bytes .../chrome/127.0.6533.119/linux-amd64/chrome | Bin 0 -> 277 bytes 4 files changed, 33 insertions(+) create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/chrome/126.0.6478.182/linux-amd64/chrome create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/chrome/127.0.6533.119/linux-amd64/chrome diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index f2e4fe207..ec0ecf12a 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -1342,6 +1342,28 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("jq-binary"), }, }, + { + logicalFixture: "chrome/126.0.6478.182/linux-amd64", + expected: pkg.Package{ + Name: "chrome", + Version: "126.0.6478.182", + Type: "binary", + PURL: "pkg:generic/chrome@126.0.6478.182", + Locations: locations("chrome"), + Metadata: metadata("chrome-binary"), + }, + }, + { + logicalFixture: "chrome/127.0.6533.119/linux-amd64", + expected: pkg.Package{ + Name: "chrome", + Version: "127.0.6533.119", + Type: "binary", + PURL: "pkg:generic/chrome@127.0.6533.119", + Locations: locations("chrome"), + Metadata: metadata("chrome-binary"), + }, + }, } for _, test := range tests { diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index dc3ff40f3..558d613c5 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -670,6 +670,17 @@ func DefaultClassifiers() []Classifier { PURL: mustPURL("pkg:generic/jq@version"), CPEs: singleCPE("cpe:2.3:a:jqlang:jq:*:*:*:*:*:*:*:*", cpe.NVDDictionaryLookupSource), }, + { + Class: "chrome-binary", + FileGlob: "**/chrome", + EvidenceMatcher: FileContentsVersionMatcher( + // [NUL]127.0.6533.119[NUL]Default + `\x00(?P[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\x00Default`, + ), + Package: "chrome", + PURL: mustPURL("pkg:generic/chrome@version"), + CPEs: singleCPE("cpe:2.3:a:google:chrome:*:*:*:*:*:*:*:*"), + }, } } diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/chrome/126.0.6478.182/linux-amd64/chrome b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/chrome/126.0.6478.182/linux-amd64/chrome new file mode 100644 index 0000000000000000000000000000000000000000..14c0dca81c4d29997e7f67e6e7db03a59f6d3f86 GIT binary patch literal 277 zcmYL^O>4v;6h&S8D}?Nm_!*n^Yzu`#_r~{Zq(+CRO#AOUln!%umkalBvO92Pem~2B zw1iNxt*qy-TyB{r%%5$4_L}4MitT-OLYtLoua?<@2w*Hqy_n#YvalGbXYe-gAc31; z1fRKC19re4pf?(W3t z&ms0>!taK;#*!!eAQb_eoUPzh9dpmu-1Xj)a@Y|FNs?FMJ&*S%~& zO9%+{%v!$X^2jtn{;unrV~+Pb)az=6nvRt924*GA