mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
set cataloger names within package cataloger task (#3165)
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
parent
99be365f62
commit
4ee6c179f8
@ -81,7 +81,7 @@ func (f PackageTaskFactories) Tasks(cfg CatalogingFactoryConfig) ([]Task, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewPackageTask creates a Task function for a generic pkg.Cataloger, honoring the common configuration options.
|
// NewPackageTask creates a Task function for a generic pkg.Cataloger, honoring the common configuration options.
|
||||||
func NewPackageTask(cfg CatalogingFactoryConfig, c pkg.Cataloger, tags ...string) Task {
|
func NewPackageTask(cfg CatalogingFactoryConfig, c pkg.Cataloger, tags ...string) Task { //nolint: funlen
|
||||||
fn := func(ctx context.Context, resolver file.Resolver, sbom sbomsync.Builder) error {
|
fn := func(ctx context.Context, resolver file.Resolver, sbom sbomsync.Builder) error {
|
||||||
catalogerName := c.Name()
|
catalogerName := c.Name()
|
||||||
log.WithFields("name", catalogerName).Trace("starting package cataloger")
|
log.WithFields("name", catalogerName).Trace("starting package cataloger")
|
||||||
@ -100,12 +100,15 @@ func NewPackageTask(cfg CatalogingFactoryConfig, c pkg.Cataloger, tags ...string
|
|||||||
|
|
||||||
pkgs, relationships, err := c.Catalog(ctx, resolver)
|
pkgs, relationships, err := c.Catalog(ctx, resolver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to catalog packages with %q: %w", c.Name(), err)
|
return fmt.Errorf("unable to catalog packages with %q: %w", catalogerName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.WithFields("cataloger", c.Name()).Debugf("discovered %d packages", len(pkgs))
|
log.WithFields("cataloger", catalogerName).Debugf("discovered %d packages", len(pkgs))
|
||||||
|
|
||||||
for i, p := range pkgs {
|
for i, p := range pkgs {
|
||||||
|
if p.FoundBy == "" {
|
||||||
|
p.FoundBy = catalogerName
|
||||||
|
}
|
||||||
if cfg.DataGenerationConfig.GenerateCPEs {
|
if cfg.DataGenerationConfig.GenerateCPEs {
|
||||||
// generate CPEs (note: this is excluded from package ID, so is safe to mutate)
|
// generate CPEs (note: this is excluded from package ID, so is safe to mutate)
|
||||||
// we might have binary classified CPE already with the package so we want to append here
|
// we might have binary classified CPE already with the package so we want to append here
|
||||||
@ -143,7 +146,7 @@ func NewPackageTask(cfg CatalogingFactoryConfig, c pkg.Cataloger, tags ...string
|
|||||||
t.Add(int64(len(pkgs)))
|
t.Add(int64(len(pkgs)))
|
||||||
|
|
||||||
t.SetCompleted()
|
t.SetCompleted()
|
||||||
log.WithFields("name", c.Name()).Trace("package cataloger completed")
|
log.WithFields("name", catalogerName).Trace("package cataloger completed")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user