-
Notifications
You must be signed in to change notification settings - Fork 856
Option to enable specific language or ecosystem cataloger #843
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
Changes from all commits
363899d
8fe4d55
911a214
d3ab442
1a84ae9
38ebf4a
247e644
0ad634f
e475586
5382603
0728819
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -367,6 +367,24 @@ package: | |
| # same as -s ; SYFT_PACKAGE_CATALOGER_SCOPE env var | ||
| scope: "squashed" | ||
|
|
||
| # enable specific language or ecosystem cataloger | ||
| # default: all catalogers are enabled by default | ||
| # enable-cataloger: | ||
| # - "ruby-gemfile-cataloger" | ||
| # - "ruby-gemspec-cataloger" | ||
| # - "python-index-cataloger" | ||
| # - "python-package-cataloger" | ||
| # - "javascript-lock-cataloger" | ||
| # - "javascript-package-cataloger" | ||
| # - "php-composer-installed-cataloger" | ||
| # - "php-composer-lock-cataloger" | ||
| # - "dpkgdb-cataloger" | ||
| # - "rpmdb-cataloger" | ||
| # - "java-cataloger" | ||
| # - "apkdb-cataloger" | ||
| # - "go-module-binary-cataloger" | ||
| enable-cataloger: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: since this takes multiple values it should probably be |
||
|
|
||
| # cataloging file classifications is exposed through the power-user subcommand | ||
| file-classification: | ||
| cataloger: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import ( | |
| "github.com/anchore/syft/syft/pkg/cataloger/apkdb" | ||
| "github.com/anchore/syft/syft/pkg/cataloger/dart" | ||
| "github.com/anchore/syft/syft/pkg/cataloger/deb" | ||
| "github.com/anchore/syft/syft/pkg/cataloger/dotnet" | ||
| //"github.com/anchore/syft/syft/pkg/cataloger/dotnet" | ||
| "github.com/anchore/syft/syft/pkg/cataloger/golang" | ||
| "github.com/anchore/syft/syft/pkg/cataloger/java" | ||
| "github.com/anchore/syft/syft/pkg/cataloger/javascript" | ||
|
|
@@ -35,7 +35,7 @@ type Cataloger interface { | |
|
|
||
| // ImageCatalogers returns a slice of locally implemented catalogers that are fit for detecting installations of packages. | ||
| func ImageCatalogers(cfg Config) []Cataloger { | ||
| return []Cataloger{ | ||
| return filterCatalogers([]Cataloger{ | ||
| ruby.NewGemSpecCataloger(), | ||
| python.NewPythonPackageCataloger(), | ||
| php.NewPHPComposerInstalledCataloger(), | ||
|
|
@@ -45,13 +45,13 @@ func ImageCatalogers(cfg Config) []Cataloger { | |
| java.NewJavaCataloger(cfg.Java()), | ||
| apkdb.NewApkdbCataloger(), | ||
| golang.NewGoModuleBinaryCataloger(), | ||
| dotnet.NewDotnetDepsCataloger(), | ||
| } | ||
| //dotnet.NewDotnetDepsCataloger(), | ||
| }, cfg.EnabledCatalogers) | ||
| } | ||
|
|
||
| // DirectoryCatalogers returns a slice of locally implemented catalogers that are fit for detecting packages from index files (and select installations) | ||
| func DirectoryCatalogers(cfg Config) []Cataloger { | ||
| return []Cataloger{ | ||
| return filterCatalogers([]Cataloger{ | ||
| ruby.NewGemFileLockCataloger(), | ||
| python.NewPythonIndexCataloger(), | ||
| python.NewPythonPackageCataloger(), | ||
|
|
@@ -65,13 +65,13 @@ func DirectoryCatalogers(cfg Config) []Cataloger { | |
| golang.NewGoModFileCataloger(), | ||
| rust.NewCargoLockCataloger(), | ||
| dart.NewPubspecLockCataloger(), | ||
| dotnet.NewDotnetDepsCataloger(), | ||
| } | ||
| //dotnet.NewDotnetDepsCataloger(), | ||
| }, cfg.EnabledCatalogers) | ||
| } | ||
|
|
||
| // AllCatalogers returns all implemented catalogers | ||
| func AllCatalogers(cfg Config) []Cataloger { | ||
| return []Cataloger{ | ||
| return filterCatalogers([]Cataloger{ | ||
| ruby.NewGemFileLockCataloger(), | ||
| ruby.NewGemSpecCataloger(), | ||
| python.NewPythonIndexCataloger(), | ||
|
|
@@ -86,6 +86,29 @@ func AllCatalogers(cfg Config) []Cataloger { | |
| golang.NewGoModFileCataloger(), | ||
| rust.NewCargoLockCataloger(), | ||
| dart.NewPubspecLockCataloger(), | ||
| dotnet.NewDotnetDepsCataloger(), | ||
| //dotnet.NewDotnetDepsCataloger(), | ||
| }, cfg.EnabledCatalogers) | ||
| } | ||
|
|
||
| func filterCatalogers(catalogers []Cataloger, enabledCatalogers []string) []Cataloger { | ||
| // if enable-cataloger is not set, all applicable catalogers are enabled by default | ||
| if len(enabledCatalogers) == 0 { | ||
| return catalogers | ||
| } | ||
| var filteredCatalogers []Cataloger | ||
| for _, cataloger := range catalogers { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could add additional logic such that the string |
||
| if contains(enabledCatalogers, cataloger.Name()) { | ||
| filteredCatalogers = append(filteredCatalogers, cataloger) | ||
| } | ||
| } | ||
| return filteredCatalogers | ||
| } | ||
|
|
||
| func contains(catalogers []string, str string) bool { | ||
| for _, cataloger := range catalogers { | ||
| if cataloger == str { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: mentioning that all catalogers are enabled by default is a little misleading. There is still a selection of which catalogers to use based off of the source (dir scan or image scan)