From 73b9d5aa4262186bd343ffc58f138382a0b5db0f Mon Sep 17 00:00:00 2001 From: Keith Zantow Date: Wed, 21 Aug 2024 09:48:28 -0400 Subject: [PATCH] fix: mysql 8.0.3x binary detection (#3142) Signed-off-by: Keith Zantow --- .../binary/classifier_cataloger_test.go | 11 +++++++++++ syft/pkg/cataloger/binary/classifiers.go | 8 ++++++-- .../snippets/mysql/8.0.34/linux-amd64/mysql | Bin 329 -> 349 bytes .../snippets/mysql/8.0.37/linux-amd64/mysql | Bin 0 -> 349 bytes .../cataloger/binary/test-fixtures/config.yaml | 7 +++++++ 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/mysql/8.0.37/linux-amd64/mysql diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index dcc9849c675..721ee9ee045 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -116,6 +116,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("mysql-binary"), }, }, + { + logicalFixture: "mysql/8.0.37/linux-amd64", + expected: pkg.Package{ + Name: "mysql", + Version: "8.0.37", + Type: "binary", + PURL: "pkg:generic/mysql@8.0.37", + Locations: locations("mysql"), + Metadata: metadata("mysql-binary"), + }, + }, { logicalFixture: "percona-server/8.0.35/linux-amd64", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index 0d491f25feb..5f4d3aa6651 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -294,8 +294,12 @@ func DefaultClassifiers() []Classifier { { Class: "mysql-binary", FileGlob: "**/mysql", - EvidenceMatcher: FileContentsVersionMatcher( - `(?m).*/mysql-(?P[0-9]+(\.[0-9]+)?(\.[0-9]+)?(alpha[0-9]|beta[0-9]|rc[0-9])?)`), + EvidenceMatcher: evidenceMatchers( + // shutdown[NUL]8.0.37[NUL][NUL][NUL][NUL][NUL]mysql_real_esc + FileContentsVersionMatcher(`\x00(?P[0-9]+(\.[0-9]+)?(\.[0-9]+)?(alpha[0-9]|beta[0-9]|rc[0-9])?)\x00+mysql`), + // /export/home/pb2/build/sb_0-26781090-1516292385.58/release/mysql-8.0.4-rc/mysys_ssl/my_default.cc + FileContentsVersionMatcher(`(?m).*/mysql-(?P[0-9]+(\.[0-9]+)?(\.[0-9]+)?(alpha[0-9]|beta[0-9]|rc[0-9])?)`), + ), Package: "mysql", PURL: mustPURL("pkg:generic/mysql@version"), CPEs: singleCPE("cpe:2.3:a:oracle:mysql:*:*:*:*:*:*:*:*"), diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/mysql/8.0.34/linux-amd64/mysql b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/mysql/8.0.34/linux-amd64/mysql index 571e977876d514a60f30550a982ec3942e92497f..9ff7ddd39cee298be9fcdaf561a6df90cd313d1e 100644 GIT binary patch delta 227 zcmZ{ZOAdlC6aa}!FW{CFkhYXk+`BTtL}Ogm*YXM`SkTs}x6osG2+!eXB^Pj#Sxn|J zdX8?BEzL+VZqe1DnZ}fnv3I+^$FOREWnvmznGp_l2%uW#R01cA5o5Ff0lGqAq())$ z6bsI5Wi(ct7rDiZ<{Z-d*K?VIBP#GVgiU_GmWS{NoB`wL_}*vm z9y}+z1hg5Iq26DL*%YK4we_KC!ew1Jg?2X0fmj8V*Z@SHHA+?<1Co@4o+&4fE-1<& zaB4uK(vE_|)KJDL!RuE0uHOy2{xR-)adl@=9#}N2M9W)<04PCaWCWHHqYYRcODoPz dCFYyuY9Xq7dnzM}WvtCVexDty>R5}c`~v5jKnnl> diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/mysql/8.0.37/linux-amd64/mysql b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/mysql/8.0.37/linux-amd64/mysql new file mode 100644 index 0000000000000000000000000000000000000000..45109e6f731ebcb52bb16f15e011ad92c23cf834 GIT binary patch literal 349 zcmZ`!O>4t249(fU!q9v1ryS?L)1ZTuv19Ou+yv4%ZCpx!`94lFTgOh5csz+GJ*3$k zv7^V^dYVX1X~oh}u9X31$b|Eu47C@Gtn;`mSoVVx8agUH0|U-8Q3s<*(T5gL3hhne z$~vw&xCkOx6e(KmeJ~20V@c?cWF%>v@Yf7w^k9TmyfvOB00gT8kFHIqICzMxl|jau zCPZ-PqwuXY(rVCJSwc3O4fVHz^nNBSnWj8V`AVxq9(PZ#yZ&YW@Z7A!rNn%ln|8~# r(lkHu{eOQ(H}$v%w_v}P^Ee;+(Cw& 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 50dd6bcc8ed..9ea3c2de71f 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/config.yaml +++ b/syft/pkg/cataloger/binary/test-fixtures/config.yaml @@ -157,6 +157,13 @@ from-images: paths: - /usr/bin/mysql + - version: 8.0.37 + images: + - ref: mysql:8.0.37-bookworm@sha256:bad55a5bb69d6710927792384b5eb55669ee15dc85dca1888874e4a7993eecd8 + platform: linux/amd64 + paths: + - /usr/bin/mysql + - name: percona-server version: 8.0.35 images: