mirror of
https://github.com/anchore/syft.git
synced 2026-11-04 00:16:38 +01:00
feat: license file search (#4327)
Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/anchore/packageurl-go"
|
||||
"github.com/anchore/syft/syft/file"
|
||||
"github.com/anchore/syft/syft/pkg"
|
||||
"github.com/anchore/syft/syft/pkg/cataloger/internal/licenses"
|
||||
)
|
||||
|
||||
func newGemfileLockPackage(name, version string, locations ...file.Location) pkg.Package {
|
||||
@@ -23,7 +24,7 @@ func newGemfileLockPackage(name, version string, locations ...file.Location) pkg
|
||||
return p
|
||||
}
|
||||
|
||||
func newGemspecPackage(ctx context.Context, m gemData, gemSpecLocation file.Location) pkg.Package {
|
||||
func newGemspecPackage(ctx context.Context, resolver file.Resolver, m gemData, gemSpecLocation file.Location) pkg.Package {
|
||||
p := pkg.Package{
|
||||
Name: m.Name,
|
||||
Version: m.Version,
|
||||
@@ -37,6 +38,8 @@ func newGemspecPackage(ctx context.Context, m gemData, gemSpecLocation file.Loca
|
||||
|
||||
p.SetID()
|
||||
|
||||
p = licenses.RelativeToPackage(ctx, resolver, p)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ func processList(s string) []string {
|
||||
}
|
||||
|
||||
// parseGemSpecEntries parses the gemspec file and returns the packages and relationships found.
|
||||
func parseGemSpecEntries(ctx context.Context, _ file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
|
||||
func parseGemSpecEntries(ctx context.Context, resolver file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
|
||||
var pkgs []pkg.Package
|
||||
var fields = make(map[string]interface{})
|
||||
scanner := bufio.NewScanner(reader)
|
||||
@@ -106,6 +106,7 @@ func parseGemSpecEntries(ctx context.Context, _ file.Resolver, _ *generic.Enviro
|
||||
pkgs,
|
||||
newGemspecPackage(
|
||||
ctx,
|
||||
resolver,
|
||||
metadata,
|
||||
reader.Location,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user