mirror of
https://github.com/anchore/syft.git
synced 2026-02-12 10:36:45 +01:00
chore: restore cataloger.DefaultConfig (#2028)
Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
parent
b3d7ba569b
commit
59107324ce
@ -18,6 +18,16 @@ type Config struct {
|
|||||||
ExcludeBinaryOverlapByOwnership bool
|
ExcludeBinaryOverlapByOwnership bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DefaultConfig() Config {
|
||||||
|
return Config{
|
||||||
|
Search: DefaultSearchConfig(),
|
||||||
|
Parallelism: 1,
|
||||||
|
LinuxKernel: kernel.DefaultLinuxCatalogerConfig(),
|
||||||
|
Python: python.DefaultCatalogerConfig(),
|
||||||
|
ExcludeBinaryOverlapByOwnership: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c Config) Java() java.Config {
|
func (c Config) Java() java.Config {
|
||||||
return java.Config{
|
return java.Config{
|
||||||
SearchUnindexedArchives: c.Search.IncludeUnindexedArchives,
|
SearchUnindexedArchives: c.Search.IncludeUnindexedArchives,
|
||||||
|
|||||||
@ -23,7 +23,7 @@ func BenchmarkImagePackageCatalogers(b *testing.B) {
|
|||||||
tarPath := imagetest.GetFixtureImageTarPath(b, fixtureImageName)
|
tarPath := imagetest.GetFixtureImageTarPath(b, fixtureImageName)
|
||||||
|
|
||||||
var pc *pkg.Collection
|
var pc *pkg.Collection
|
||||||
for _, c := range cataloger.ImageCatalogers(defaultConfig()) {
|
for _, c := range cataloger.ImageCatalogers(cataloger.DefaultConfig()) {
|
||||||
// in case of future alteration where state is persisted, assume no dependency is safe to reuse
|
// in case of future alteration where state is persisted, assume no dependency is safe to reuse
|
||||||
userInput := "docker-archive:" + tarPath
|
userInput := "docker-archive:" + tarPath
|
||||||
detection, err := source.Detect(userInput, source.DefaultDetectConfig())
|
detection, err := source.Detect(userInput, source.DefaultDetectConfig())
|
||||||
@ -260,7 +260,7 @@ func TestPkgCoverageCatalogerConfiguration(t *testing.T) {
|
|||||||
assert.Equal(t, definedLanguages, observedLanguages)
|
assert.Equal(t, definedLanguages, observedLanguages)
|
||||||
|
|
||||||
// Verify that rust isn't actually an image cataloger
|
// Verify that rust isn't actually an image cataloger
|
||||||
c := defaultConfig()
|
c := cataloger.DefaultConfig()
|
||||||
c.Catalogers = []string{"rust"}
|
c.Catalogers = []string{"rust"}
|
||||||
assert.Len(t, cataloger.ImageCatalogers(c), 0)
|
assert.Len(t, cataloger.ImageCatalogers(c), 0)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,8 +8,6 @@ import (
|
|||||||
"github.com/anchore/stereoscope/pkg/imagetest"
|
"github.com/anchore/stereoscope/pkg/imagetest"
|
||||||
"github.com/anchore/syft/syft"
|
"github.com/anchore/syft/syft"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger"
|
"github.com/anchore/syft/syft/pkg/cataloger"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/kernel"
|
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/python"
|
|
||||||
"github.com/anchore/syft/syft/sbom"
|
"github.com/anchore/syft/syft/sbom"
|
||||||
"github.com/anchore/syft/syft/source"
|
"github.com/anchore/syft/syft/source"
|
||||||
)
|
)
|
||||||
@ -26,7 +24,7 @@ func catalogFixtureImage(t *testing.T, fixtureImageName string, scope source.Sco
|
|||||||
theSource.Close()
|
theSource.Close()
|
||||||
})
|
})
|
||||||
|
|
||||||
c := defaultConfig()
|
c := cataloger.DefaultConfig()
|
||||||
c.Catalogers = catalogerCfg
|
c.Catalogers = catalogerCfg
|
||||||
|
|
||||||
c.Search.Scope = scope
|
c.Search.Scope = scope
|
||||||
@ -54,16 +52,6 @@ func catalogFixtureImage(t *testing.T, fixtureImageName string, scope source.Sco
|
|||||||
}, theSource
|
}, theSource
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultConfig() cataloger.Config {
|
|
||||||
return cataloger.Config{
|
|
||||||
Search: cataloger.DefaultSearchConfig(),
|
|
||||||
Parallelism: 1,
|
|
||||||
LinuxKernel: kernel.DefaultLinuxCatalogerConfig(),
|
|
||||||
Python: python.DefaultCatalogerConfig(),
|
|
||||||
ExcludeBinaryOverlapByOwnership: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func catalogDirectory(t *testing.T, dir string) (sbom.SBOM, source.Source) {
|
func catalogDirectory(t *testing.T, dir string) (sbom.SBOM, source.Source) {
|
||||||
userInput := "dir:" + dir
|
userInput := "dir:" + dir
|
||||||
detection, err := source.Detect(userInput, source.DefaultDetectConfig())
|
detection, err := source.Detect(userInput, source.DefaultDetectConfig())
|
||||||
@ -75,7 +63,7 @@ func catalogDirectory(t *testing.T, dir string) (sbom.SBOM, source.Source) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// TODO: this would be better with functional options (after/during API refactor)
|
// TODO: this would be better with functional options (after/during API refactor)
|
||||||
c := defaultConfig()
|
c := cataloger.DefaultConfig()
|
||||||
c.Search.Scope = source.AllLayersScope
|
c.Search.Scope = source.AllLayersScope
|
||||||
pkgCatalog, relationships, actualDistro, err := syft.CatalogPackages(theSource, c)
|
pkgCatalog, relationships, actualDistro, err := syft.CatalogPackages(theSource, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user