From 6ebe4de62c60098ee3efb06baf82f3b50ae9b77c Mon Sep 17 00:00:00 2001 From: witchcraze Date: Fri, 17 Mar 2023 16:42:23 +0900 Subject: [PATCH] fix ruby classifier Signed-off-by: witchcraze --- syft/pkg/cataloger/binary/cataloger_test.go | 17 +++++++++++++++++ .../pkg/cataloger/binary/default_classifiers.go | 2 +- .../pkg/cataloger/binary/test-fixtures/Makefile | 13 +++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/syft/pkg/cataloger/binary/cataloger_test.go b/syft/pkg/cataloger/binary/cataloger_test.go index 5977abd77b5..a35d3cced6e 100644 --- a/syft/pkg/cataloger/binary/cataloger_test.go +++ b/syft/pkg/cataloger/binary/cataloger_test.go @@ -685,6 +685,23 @@ func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) { }, }, }, + { + name: "positive-ruby-2.6.10", + fixtureDir: "test-fixtures/classifiers/dynamic/ruby-library-2.6.10", + expected: pkg.Package{ + Name: "ruby", + Version: "2.6.10p210", + Type: "binary", + PURL: "pkg:generic/ruby@2.6.10p210", + Locations: locations("ruby", "libruby.so.2.6.10"), + Metadata: pkg.BinaryMetadata{ + Matches: []pkg.ClassifierMatch{ + match("ruby-binary", "ruby"), + match("ruby-binary", "libruby.so.2.6.10"), + }, + }, + }, + }, { name: "positive-ruby-1.9.3p551", fixtureDir: "test-fixtures/classifiers/positive/ruby-1.9.3p551", diff --git a/syft/pkg/cataloger/binary/default_classifiers.go b/syft/pkg/cataloger/binary/default_classifiers.go index 852ff323eff..a80f9676fdf 100644 --- a/syft/pkg/cataloger/binary/default_classifiers.go +++ b/syft/pkg/cataloger/binary/default_classifiers.go @@ -283,4 +283,4 @@ var libpythonMatcher = fileNameTemplateVersionMatcher( var rubyMatcher = fileContentsVersionMatcher( // 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[0-9]\.[0-9]\.[0-9](p[0-9]+)?) `) + `(?m)ruby (?P[0-9]+\.[0-9]+\.[0-9]+(p[0-9]+)?) `) diff --git a/syft/pkg/cataloger/binary/test-fixtures/Makefile b/syft/pkg/cataloger/binary/test-fixtures/Makefile index d6db7455978..8631701256f 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/Makefile +++ b/syft/pkg/cataloger/binary/test-fixtures/Makefile @@ -6,6 +6,7 @@ all: \ classifiers/dynamic/python-binary-3.4-alpine \ classifiers/dynamic/ruby-library-3.2.1 \ classifiers/dynamic/ruby-library-2.7.7 \ + classifiers/dynamic/ruby-library-2.6.10 \ classifiers/dynamic/argocd-2.5.11 \ classifiers/dynamic/argocd-2.6.4 \ classifiers/dynamic/helm-3.11.1 \ @@ -74,6 +75,18 @@ classifiers/dynamic/ruby-library-2.7.7: /usr/local/lib/libruby.so.2.7 \ $@/libruby.so.2.7 +classifiers/dynamic/ruby-library-2.6.10: + $(eval $@_image := "ruby:2.6.10@sha256:771a810704167e55da8a19970c5dfa6eb795dfee32547adffa29ea72703f7243") + ./get-image-file.sh $($@_image) \ + /usr/local/bin/ruby \ + $@/ruby + ./get-image-file.sh $($@_image) \ + /usr/local/lib/libruby.so.2.6.10 \ + $@/libruby.so.2.6.10 + ./get-image-file.sh $($@_image) \ + /usr/local/lib/libruby.so.2.6 \ + $@/libruby.so.2.6 + classifiers/dynamic/argocd-2.5.11: $(eval $@_image := "argoproj/argocd:v2.5.11@sha256:d1062935b3256ec69422843ebcb50debb54fd389436961586000c8ce6ee7f249") ./get-image-file.sh $($@_image) \