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 ruby classifier #3285

Merged
merged 1 commit into from
Sep 27, 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
54 changes: 54 additions & 0 deletions syft/pkg/cataloger/binary/classifier_cataloger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,60 @@ func Test_Cataloger_PositiveCases(t *testing.T) {
},
},
},
{
// note: dynamic (non-snippet) test case
name: "positive-ruby-3.4.0-dev",
logicalFixture: "ruby-shared-libs/3.4.0-dev/linux-amd64",
expected: pkg.Package{
Name: "ruby",
Version: "3.4.0dev",
Type: "binary",
PURL: "pkg:generic/[email protected]",
Locations: locations("ruby", "libruby.so.3.4.0"),
Metadata: pkg.BinarySignature{
Matches: []pkg.ClassifierMatch{
match("ruby-binary", "ruby"),
match("ruby-binary", "libruby.so.3.4.0"),
},
},
},
},
{
// note: dynamic (non-snippet) test case
name: "positive-ruby-3.4.0-preview1",
logicalFixture: "ruby-shared-libs/3.4.0-preview1/linux-amd64",
expected: pkg.Package{
Name: "ruby",
Version: "3.4.0preview1",
Type: "binary",
PURL: "pkg:generic/[email protected]",
Locations: locations("ruby", "libruby.so.3.4.0"),
Metadata: pkg.BinarySignature{
Matches: []pkg.ClassifierMatch{
match("ruby-binary", "ruby"),
match("ruby-binary", "libruby.so.3.4.0"),
},
},
},
},
{
// note: dynamic (non-snippet) test case
name: "positive-ruby-3.3.0-rc1",
logicalFixture: "ruby-shared-libs/3.3.0-rc1/linux-amd64",
expected: pkg.Package{
Name: "ruby",
Version: "3.3.0rc1",
Type: "binary",
PURL: "pkg:generic/[email protected]",
Locations: locations("ruby", "libruby.so.3.3.0"),
Metadata: pkg.BinarySignature{
Matches: []pkg.ClassifierMatch{
match("ruby-binary", "ruby"),
match("ruby-binary", "libruby.so.3.3.0"),
},
},
},
},
{
// note: dynamic (non-snippet) test case
logicalFixture: "ruby-bullseye-shared-libs/2.7.7/linux-amd64",
Expand Down
5 changes: 4 additions & 1 deletion syft/pkg/cataloger/binary/classifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,9 @@ var libpythonMatcher = fileNameTemplateVersionMatcher(
)

var rubyMatcher = FileContentsVersionMatcher(
// ruby 3.4.0dev (2024-09-15T01:06:11Z master 532af89e3b) [x86_64-linux]
// ruby 3.4.0preview1 (2024-05-16 master 9d69619623) [x86_64-linux]
// ruby 3.3.0rc1 (2023-12-11 master a49643340e) [x86_64-linux]
// ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
// ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [x86_64-linux]
`(?m)ruby (?P<version>[0-9]+\.[0-9]+\.[0-9]+(p[0-9]+)?) `)
`(?m)ruby (?P<version>[0-9]+\.[0-9]+\.[0-9]+((p|preview|rc|dev)[0-9]*)?) `)
30 changes: 30 additions & 0 deletions syft/pkg/cataloger/binary/test-fixtures/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,36 @@ from-images:
- /usr/local/lib/libruby.so.2.7.7
- /usr/local/lib/libruby.so.2.7

- name: ruby-shared-libs
version: 3.4.0-dev
images:
- ref: rubylang/ruby:master-dev-nightly-20240804-focal@sha256:b5fe8b9ac1e9638a4b08bda6a6343082a07623d1c01926e637eb4bbbbf159409
platform: linux/amd64
paths:
- /usr/local/bin/ruby
- /usr/local/lib/libruby.so.3.4.0
- /usr/local/lib/libruby.so.3.4

- name: ruby-shared-libs
version: 3.4.0-preview1
images:
- ref: ruby:3.4.0-preview1@sha256:88cad31539e1a4ab987ac4b00c45b86d8346c25e3b08ac647ccccfb21cee5890
platform: linux/amd64
paths:
- /usr/local/bin/ruby
- /usr/local/lib/libruby.so.3.4.0
- /usr/local/lib/libruby.so.3.4

- name: ruby-shared-libs
version: 3.3.0-rc1
images:
- ref: ruby:3.3.0-rc1@sha256:453c8bbb9b4e3b04b94ba58db77b648222f3c92936dc12b5ae96df48076c106b
platform: linux/amd64
paths:
- /usr/local/bin/ruby
- /usr/local/lib/libruby.so.3.3.0
- /usr/local/lib/libruby.so.3.3

- name: ruby-shared-libs
version: 2.6.10
images:
Expand Down
Loading