Skip to content

Commit

Permalink
Add ruby.NewGemSpecCataloger to DirectoryCatalogers. (#1971)
Browse files Browse the repository at this point in the history
* Add ruby.NewGemSpecCataloger to DirectoryCatalogers.

Signed-off-by: Evan <chaol@vmware.com>

* fixed tests

Signed-off-by: Evan <chaol@vmware.com>

* Addressed review comment

Signed-off-by: Evan <chaol@vmware.com>

* Remove NewInstalledGemSpecCataloger from default dir catalogers

Because the files that the installed gemspec cataloger work off of are a
subset of the files that the more general gemspec cataloger will work
off of, we shouldn't have both of them on by default, since this could
result in finding the same package twice.

Signed-off-by: Will Murphy <will.murphy@anchore.com>

---------

Signed-off-by: Evan <chaol@vmware.com>
Signed-off-by: Will Murphy <will.murphy@anchore.com>
Co-authored-by: Will Murphy <will.murphy@anchore.com>
  • Loading branch information
evanchaoli and willmurphyscode authored Oct 23, 2023
1 parent 263be01 commit 671ff39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion syft/pkg/cataloger/cataloger.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func ImageCatalogers(cfg Config) []pkg.Cataloger {
python.NewPythonPackageCataloger(),
r.NewPackageCataloger(),
rpm.NewRpmDBCataloger(),
ruby.NewGemSpecCataloger(),
ruby.NewInstalledGemSpecCataloger(),
sbom.NewSBOMCataloger(),
}, cfg.Catalogers)
}
Expand Down Expand Up @@ -93,6 +93,7 @@ func DirectoryCatalogers(cfg Config) []pkg.Cataloger {
rpm.NewFileCataloger(),
rpm.NewRpmDBCataloger(),
ruby.NewGemFileLockCataloger(),
ruby.NewGemSpecCataloger(),
rust.NewCargoLockCataloger(),
sbom.NewSBOMCataloger(),
swift.NewCocoapodsCataloger(),
Expand Down Expand Up @@ -136,6 +137,7 @@ func AllCatalogers(cfg Config) []pkg.Cataloger {
rpm.NewRpmDBCataloger(),
ruby.NewGemFileLockCataloger(),
ruby.NewGemSpecCataloger(),
ruby.NewInstalledGemSpecCataloger(),
rust.NewAuditBinaryCataloger(),
rust.NewCargoLockCataloger(),
sbom.NewSBOMCataloger(),
Expand Down
10 changes: 8 additions & 2 deletions syft/pkg/cataloger/ruby/catalogers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ func NewGemFileLockCataloger() *generic.Cataloger {
WithParserByGlobs(parseGemFileLockEntries, "**/Gemfile.lock")
}

// NewGemSpecCataloger returns a new Bundler cataloger object tailored for detecting installations of gems (e.g. Gemspec).
func NewGemSpecCataloger() *generic.Cataloger {
// NewInstalledGemSpecCataloger returns a new Bundler cataloger object tailored for detecting installations of gems (e.g. Gemspec).
func NewInstalledGemSpecCataloger() *generic.Cataloger {
return generic.NewCataloger("ruby-gemspec-cataloger").
WithParserByGlobs(parseGemSpecEntries, "**/specifications/**/*.gemspec")
}

// NewGemSpecCataloger looks for gems with a broader scope.
func NewGemSpecCataloger() *generic.Cataloger {
return generic.NewCataloger("ruby-gemspec-cataloger").
WithParserByGlobs(parseGemSpecEntries, "**/*.gemspec")
}
2 changes: 2 additions & 0 deletions test/integration/catalog_packages_cases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ var dirOnlyTestCases = []testCase{
"arel": "5.0.1.20140414130214",
"bootstrap-sass": "3.1.1.1",
"builder": "3.2.2",
"bundler": "2.1.4",
"coffee-rails": "4.0.1",
"coffee-script": "2.2.0",
"coffee-script-source": "1.7.0",
Expand Down Expand Up @@ -136,6 +137,7 @@ var dirOnlyTestCases = []testCase{
"turbolinks": "3.0.0",
"tzinfo": "1.2.0",
"uglifier": "2.5.0",
"unbundler": "3.1.4",
"unicorn": "4.8.3",
},
},
Expand Down

0 comments on commit 671ff39

Please sign in to comment.