From 29c9857857acc73fb5443bdc36f5df0bd3633eee Mon Sep 17 00:00:00 2001 From: Andrew Garner Date: Wed, 10 Jan 2024 10:06:14 -0600 Subject: [PATCH] feat: binary classifiers for Percona Software For MySQL (#2478) Signed-off-by: Andrew Garner --- syft/pkg/cataloger/binary/cataloger_test.go | 33 +++++++++++++++++ .../cataloger/binary/default_classifiers.go | 34 ++++++++++++++++++ .../percona-server/8.0.35/linux-amd64/mysql | Bin 0 -> 349 bytes .../8.0.35/linux-amd64/xtrabackup | Bin 0 -> 355 bytes .../8.0.34/linux-amd64/mysql | Bin 0 -> 349 bytes .../binary/test-fixtures/config.yaml | 24 +++++++++++++ 6 files changed, 91 insertions(+) create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/percona-server/8.0.35/linux-amd64/mysql create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/percona-xtrabackup/8.0.35/linux-amd64/xtrabackup create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/percona-xtradb-cluster/8.0.34/linux-amd64/mysql diff --git a/syft/pkg/cataloger/binary/cataloger_test.go b/syft/pkg/cataloger/binary/cataloger_test.go index 6724e6d80..26992889a 100644 --- a/syft/pkg/cataloger/binary/cataloger_test.go +++ b/syft/pkg/cataloger/binary/cataloger_test.go @@ -89,6 +89,39 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("mysql-binary"), }, }, + { + logicalFixture: "percona-server/8.0.35/linux-amd64", + expected: pkg.Package{ + Name: "percona-server", + Version: "8.0.35", + Type: "binary", + PURL: "pkg:generic/percona-server@8.0.35", + Locations: locations("mysql"), + Metadata: metadata("mysql-binary"), + }, + }, + { + logicalFixture: "percona-xtradb-cluster/8.0.34/linux-amd64", + expected: pkg.Package{ + Name: "percona-xtradb-cluster", + Version: "8.0.34", + Type: "binary", + PURL: "pkg:generic/percona-xtradb-cluster@8.0.34", + Locations: locations("mysql"), + Metadata: metadata("mysql-binary"), + }, + }, + { + logicalFixture: "percona-xtrabackup/8.0.35/linux-amd64", + expected: pkg.Package{ + Name: "percona-xtrabackup", + Version: "8.0.35", + Type: "binary", + PURL: "pkg:generic/percona-xtrabackup@8.0.35", + Locations: locations("xtrabackup"), + Metadata: metadata("xtrabackup-binary"), + }, + }, { logicalFixture: "mysql/5.6.51/linux-amd64", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/default_classifiers.go b/syft/pkg/cataloger/binary/default_classifiers.go index 6adc136fb..c0ef9de6b 100644 --- a/syft/pkg/cataloger/binary/default_classifiers.go +++ b/syft/pkg/cataloger/binary/default_classifiers.go @@ -247,6 +247,40 @@ func DefaultClassifiers() []Classifier { PURL: mustPURL("pkg:generic/mysql@version"), CPEs: singleCPE("cpe:2.3:a:oracle:mysql:*:*:*:*:*:*:*:*"), }, + { + Class: "mysql-binary", + FileGlob: "**/mysql", + EvidenceMatcher: FileContentsVersionMatcher( + `(?m).*/percona-server-(?P[0-9]+(\.[0-9]+)?(\.[0-9]+)?(alpha[0-9]|beta[0-9]|rc[0-9])?)`), + Package: "percona-server", + PURL: mustPURL("pkg:generic/percona-server@version"), + CPEs: []cpe.CPE{ + cpe.Must("cpe:2.3:a:oracle:mysql:*:*:*:*:*:*:*:*"), + cpe.Must("cpe:2.3:a:percona:percona_server:*:*:*:*:*:*:*:*"), + }, + }, + { + Class: "mysql-binary", + FileGlob: "**/mysql", + EvidenceMatcher: FileContentsVersionMatcher( + `(?m).*/Percona-XtraDB-Cluster-(?P[0-9]+(\.[0-9]+)?(\.[0-9]+)?(alpha[0-9]|beta[0-9]|rc[0-9])?)`), + Package: "percona-xtradb-cluster", + PURL: mustPURL("pkg:generic/percona-xtradb-cluster@version"), + CPEs: []cpe.CPE{ + cpe.Must("cpe:2.3:a:oracle:mysql:*:*:*:*:*:*:*:*"), + cpe.Must("cpe:2.3:a:percona:percona_server:*:*:*:*:*:*:*:*"), + cpe.Must("cpe:2.3:a:percona:xtradb_cluster:*:*:*:*:*:*:*:*"), + }, + }, + { + Class: "xtrabackup-binary", + FileGlob: "**/xtrabackup", + EvidenceMatcher: FileContentsVersionMatcher( + `(?m).*/percona-xtrabackup-(?P[0-9]+(\.[0-9]+)?(\.[0-9]+)?(alpha[0-9]|beta[0-9]|rc[0-9])?)`), + Package: "percona-xtrabackup", + PURL: mustPURL("pkg:generic/percona-xtrabackup@version"), + CPEs: singleCPE("cpe:2.3:a:percona:xtrabackup:*:*:*:*:*:*:*:*"), + }, { Class: "mariadb-binary", FileGlob: "**/mariadb", diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/percona-server/8.0.35/linux-amd64/mysql b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/percona-server/8.0.35/linux-amd64/mysql new file mode 100644 index 0000000000000000000000000000000000000000..ec564097f0c28ad2fb40753b1d1ffe7c873942e8 GIT binary patch literal 349 zcmX|*OK!t33`D!uDFkHg=wnN=vTM;S3S`xw2cT>+abruar8LOxYxFk@0-Q$7T zsQeny8Ug|vd}y4pTIp8$TG|ye8b(8NwM` z`cdZ)Lpoh1GM2JnZK-tJcq@VQIK0(kO9gPU4Ba$gJsbmQ(^6C^sgku#u6P$93Umg* zq!79E*-Fxq-E^;@k(zN*}tsrW~{5R&-9-1)wkGr zsO%kwQ#UN^I?ktM3JKYSa~g-x{Qc6n4R7|_-S*+IWfhmo=II+|mEA7mqS F^95p+YhM5W literal 0 HcmV?d00001 diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/percona-xtradb-cluster/8.0.34/linux-amd64/mysql b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/percona-xtradb-cluster/8.0.34/linux-amd64/mysql new file mode 100644 index 0000000000000000000000000000000000000000..1d60bcf95dd398113f4f496486ed0bba1930540b GIT binary patch literal 349 zcmXv~xlY4C5T*84SW4~edUiM7O-G0eq!fqPlfxVdLMUvIpdAFK zxpcYV!W+<{5Fiwwk(L7icxx7#5Y+-FmQYpW|1zzNDTJp$QgO_E0S>_BXgCxOC8wY` zM-QP8feg`9&K;r)!I9%sB*|>+mUP}L!OEH~xtwqy~<$cDc8b=m6aezRr|IQXu$ Y*>fE1dX?SPhcV)i={cVZ$)=C~0L1Zf`~Uy| literal 0 HcmV?d00001 diff --git a/syft/pkg/cataloger/binary/test-fixtures/config.yaml b/syft/pkg/cataloger/binary/test-fixtures/config.yaml index 05632221d..478a74d5d 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/config.yaml +++ b/syft/pkg/cataloger/binary/test-fixtures/config.yaml @@ -124,6 +124,30 @@ from-images: paths: - /usr/bin/mysql + - name: percona-server + version: 8.0.35 + images: + - ref: percona/percona-server:8.0.35@sha256:b76c455d3db1ae297449753b1054547b7910b3fd2ed4fd8c761cc1a6e202095a + platform: linux/amd64 + paths: + - /usr/bin/mysql + + - name: percona-xtrabackup + version: 8.0.35 + images: + - ref: percona/percona-xtrabackup:8.0.35@sha256:7fe6514db30384145b7387efb0f5250bc1f558dc8779ee15269a81c942bf8698 + platform: linux/amd64 + paths: + - /usr/bin/xtrabackup + + - name: percona-xtradb-cluster + version: 8.0.34 + images: + - ref: percona/percona-xtradb-cluster:8.0.34@sha256:cc5ec8d61a1eb5cccc2727932f85764151aaf4c1dd17c4c20b7c522e2fea57a8 + platform: linux/amd64 + paths: + - /usr/bin/mysql + # TODO: add pattern for mysqld # - version: 5.6.51 # images: