fix: add support for Dart SDK package dependencies (#1891)

Signed-off-by: Stephane Rufer <1128559+rufman@users.noreply.github.com>
This commit is contained in:
Stephane Rufer 2023-06-23 09:40:46 -07:00 committed by GitHub
parent 25ce245c03
commit 7943c73d3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 1 deletions

View File

@ -5,7 +5,7 @@ import (
"net/url" "net/url"
"sort" "sort"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v3"
"github.com/anchore/syft/internal/log" "github.com/anchore/syft/internal/log"
"github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/artifact"
@ -38,6 +38,23 @@ type pubspecLockDescription struct {
ResolvedRef string `yaml:"resolved-ref" mapstructure:"resolved-ref"` 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) { func parsePubspecLock(_ file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
var pkgs []pkg.Package var pkgs []pkg.Package

View File

@ -79,6 +79,19 @@ func TestParsePubspecLock(t *testing.T) {
Version: "1.6.0", 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", Name: "key_binder",
Version: "1.11.20", Version: "1.11.20",

View File

@ -36,6 +36,11 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.6.0" version: "1.6.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
key_binder: key_binder:
dependency: "direct main" dependency: "direct main"
description: description: