Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update redis classifier #3281

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -485,6 +485,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) {
Metadata: metadata("redis-binary"),
},
},
{
logicalFixture: "redis-server/7.2.5/linux-386",
expected: pkg.Package{
Name: "redis",
Version: "7.2.5",
Type: "binary",
PURL: "pkg:generic/redis@7.2.5",
Locations: locations("redis-server"),
Metadata: metadata("redis-binary"),
},
},
{
logicalFixture: "python-shared-lib/3.7.4/linux-amd64",
expected: pkg.Package{
Expand Down
2 changes: 1 addition & 1 deletion syft/pkg/cataloger/binary/classifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func DefaultClassifiers() []Classifier {
FileGlob: "**/redis-server",
EvidenceMatcher: evidenceMatchers(
FileContentsVersionMatcher(`(?s)payload %5.*?(?P<version>\d.\d\.\d\d*)[a-z0-9]{12,15}-[0-9]{19}`),
FileContentsVersionMatcher(`(?s)\x00(?P<version>\d.\d\.\d\d*)[a-z0-9]{12}-[0-9]{19}\x00.*?payload %5`),
FileContentsVersionMatcher(`(?s)\x00(?P<version>\d.\d\.\d\d*)[a-z0-9]{12,15}-[0-9]{19}\x00.*?payload %5`),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex can match a large segment of the file (large enough that a snippet can't be added to the PR and still pass the "no big binaries" lint).

I spent a little time trying to work out regex that still performed as well at matching redis server binaries but didn't have this drawback, and gave up for not having enough time. But it would be a nice follow up if someone can figure out how.

Discussed with @wagoodman offline and decided to approve as-is, since I couldn't make the regex shorter within the time box.

),
Package: "redis",
PURL: mustPURL("pkg:generic/redis@version"),
Expand Down
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 @@ -440,6 +440,13 @@ from-images:
paths:
- /usr/local/bin/redis-server

- version: 7.2.5
images:
- ref: redis:7.2.5@sha256:3b44455ef048b5f0a3a26d874c00c0f4ffe6a71a40834f2b038f816c6ad5ca4f
platform: linux/386
paths:
- /usr/local/bin/redis-server

- version: 2.9.0
images:
- ref: wordpress:cli-2.9.0-php8.3@sha256:3a008aafccc6a8d2d7ec2b069722cb43b3569b61cd833f9f2f13d74a9284746e
Expand Down
Loading