mirror of
https://github.com/anchore/syft.git
synced 2026-11-06 01:16:32 +01:00
feat: license file search (#4327)
Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package dart
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"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 newPubspecLockPackage(name string, raw pubspecLockPackage, locations ...file.Location) pkg.Package {
|
||||
@@ -29,7 +32,7 @@ func newPubspecLockPackage(name string, raw pubspecLockPackage, locations ...fil
|
||||
return p
|
||||
}
|
||||
|
||||
func newPubspecPackage(raw pubspecPackage, locations ...file.Location) pkg.Package {
|
||||
func newPubspecPackage(ctx context.Context, resolver file.Resolver, raw pubspecPackage, locations ...file.Location) pkg.Package {
|
||||
var env *pkg.DartPubspecEnvironment
|
||||
if raw.Environment.SDK != "" || raw.Environment.Flutter != "" {
|
||||
// this is required only after pubspec v2, but might have been optional before this
|
||||
@@ -58,6 +61,8 @@ func newPubspecPackage(raw pubspecPackage, locations ...file.Location) pkg.Packa
|
||||
|
||||
p.SetID()
|
||||
|
||||
p = licenses.RelativeToPackage(ctx, resolver, p)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ type dartPubspecEnvironment struct {
|
||||
Flutter string `mapstructure:"flutter" yaml:"flutter"`
|
||||
}
|
||||
|
||||
func parsePubspec(_ context.Context, _ file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
|
||||
func parsePubspec(ctx context.Context, resolver file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
|
||||
var pkgs []pkg.Package
|
||||
|
||||
dec := yaml.NewDecoder(reader)
|
||||
@@ -41,6 +41,8 @@ func parsePubspec(_ context.Context, _ file.Resolver, _ *generic.Environment, re
|
||||
|
||||
pkgs = append(pkgs,
|
||||
newPubspecPackage(
|
||||
ctx,
|
||||
resolver,
|
||||
p,
|
||||
reader.WithAnnotation(pkg.EvidenceAnnotationKey, pkg.PrimaryEvidenceAnnotation),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user