Skip to content

Commit

Permalink
fix: mysql 8.0.3x binary detection (#3142)
Browse files Browse the repository at this point in the history
Signed-off-by: Keith Zantow <kzantow@gmail.com>
  • Loading branch information
kzantow authored Aug 21, 2024
1 parent f786233 commit 73b9d5a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
11 changes: 11 additions & 0 deletions syft/pkg/cataloger/binary/classifier_cataloger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
8 changes: 6 additions & 2 deletions syft/pkg/cataloger/binary/classifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,12 @@ func DefaultClassifiers() []Classifier {
{
Class: "mysql-binary",
FileGlob: "**/mysql",
EvidenceMatcher: FileContentsVersionMatcher(
`(?m).*/mysql-(?P<version>[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<version>[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<version>[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:*:*:*:*:*:*:*:*"),
Expand Down
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions syft/pkg/cataloger/binary/test-fixtures/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 73b9d5a

Please sign in to comment.