feat: license file search (#4327)

Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
Keith Zantow
2025-11-03 14:16:05 -05:00
committed by GitHub
parent 7c154e7c37
commit a400c675fc
32 changed files with 616 additions and 210 deletions
+4 -2
View File
@@ -15,6 +15,7 @@ import (
"github.com/anchore/syft/syft/artifact"
"github.com/anchore/syft/syft/file"
"github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/pkg/cataloger/internal/licenses"
)
// storeCataloger finds package outputs installed in the Nix store location (/nix/store/*).
@@ -58,11 +59,11 @@ func (c storeCataloger) Catalog(ctx context.Context, resolver file.Resolver) ([]
}
}
pkgs, rels := c.finalizeStorePackages(prototypes, drvs)
pkgs, rels := c.finalizeStorePackages(ctx, resolver, prototypes, drvs)
return pkgs, rels, err
}
func (c storeCataloger) finalizeStorePackages(pkgPrototypes []nixStorePackage, drvs *derivations) ([]pkg.Package, []artifact.Relationship) {
func (c storeCataloger) finalizeStorePackages(ctx context.Context, resolver file.Resolver, pkgPrototypes []nixStorePackage, drvs *derivations) ([]pkg.Package, []artifact.Relationship) {
var pkgs []pkg.Package
var pkgByStorePath = make(map[string]pkg.Package)
for _, pp := range pkgPrototypes {
@@ -71,6 +72,7 @@ func (c storeCataloger) finalizeStorePackages(pkgPrototypes []nixStorePackage, d
}
p := newNixStorePackage(pp, c.name)
p = licenses.RelativeToPackage(ctx, resolver, p)
pkgs = append(pkgs, p)
pkgByStorePath[pp.Location.RealPath] = p
}