diff --git a/syft/pkg/cataloger/dart/parse_pubspec_lock.go b/syft/pkg/cataloger/dart/parse_pubspec_lock.go index 3493f8d1df8f..6de98c44a46d 100644 --- a/syft/pkg/cataloger/dart/parse_pubspec_lock.go +++ b/syft/pkg/cataloger/dart/parse_pubspec_lock.go @@ -5,7 +5,7 @@ import ( "net/url" "sort" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" "github.com/anchore/syft/internal/log" "github.com/anchore/syft/syft/artifact" @@ -38,6 +38,23 @@ type pubspecLockDescription struct { ResolvedRef string `yaml:"resolved-ref" mapstructure:"resolved-ref"` } +func (p *pubspecLockDescription) UnmarshalYAML(value *yaml.Node) error { + type pld pubspecLockDescription + var p2 pld + + if value.Decode(&p.Name) == nil { + return nil + } + + if err := value.Decode(&p2); err != nil { + return err + } + + *p = pubspecLockDescription(p2) + + return nil +} + func parsePubspecLock(_ file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) { var pkgs []pkg.Package diff --git a/syft/pkg/cataloger/dart/parse_pubspec_lock_test.go b/syft/pkg/cataloger/dart/parse_pubspec_lock_test.go index a5a972e80eb6..6db99863d572 100644 --- a/syft/pkg/cataloger/dart/parse_pubspec_lock_test.go +++ b/syft/pkg/cataloger/dart/parse_pubspec_lock_test.go @@ -79,6 +79,19 @@ func TestParsePubspecLock(t *testing.T) { Version: "1.6.0", }, }, + { + Name: "flutter", + Version: "0.0.0", + PURL: "pkg:pub/flutter@0.0.0", + Locations: fixtureLocationSet, + Language: pkg.Dart, + Type: pkg.DartPubPkg, + MetadataType: pkg.DartPubMetadataType, + Metadata: pkg.DartPubMetadata{ + Name: "flutter", + Version: "0.0.0", + }, + }, { Name: "key_binder", Version: "1.11.20", diff --git a/syft/pkg/cataloger/dart/test-fixtures/pubspec.lock b/syft/pkg/cataloger/dart/test-fixtures/pubspec.lock index c7b912f1aefc..da464c79527a 100644 --- a/syft/pkg/cataloger/dart/test-fixtures/pubspec.lock +++ b/syft/pkg/cataloger/dart/test-fixtures/pubspec.lock @@ -36,6 +36,11 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.6.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" key_binder: dependency: "direct main" description: