mirror of
https://github.com/anchore/syft.git
synced 2025-11-21 18:33:18 +01:00
* migrate location structs to file package Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * replace source.Location refs with file package call Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove hardlink test for file based catalogers Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove hardlink test for all-regular-files testing Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * migrate file resolver implementations to separate package Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * [wip] migrate resolvers to internal Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * migrate resolvers to syft/internal Signed-off-by: Alex Goodman <alex.goodman@anchore.com> --------- Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Signed-off-by: <>
57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package dart
|
|
|
|
import (
|
|
"github.com/anchore/packageurl-go"
|
|
"github.com/anchore/syft/syft/file"
|
|
"github.com/anchore/syft/syft/pkg"
|
|
)
|
|
|
|
func newPubspecLockPackage(name string, raw pubspecLockPackage, locations ...file.Location) pkg.Package {
|
|
metadata := pkg.DartPubMetadata{
|
|
Name: name,
|
|
Version: raw.Version,
|
|
HostedURL: raw.getHostedURL(),
|
|
VcsURL: raw.getVcsURL(),
|
|
}
|
|
|
|
p := pkg.Package{
|
|
Name: name,
|
|
Version: raw.Version,
|
|
Locations: file.NewLocationSet(locations...),
|
|
PURL: packageURL(metadata),
|
|
Language: pkg.Dart,
|
|
Type: pkg.DartPubPkg,
|
|
MetadataType: pkg.DartPubMetadataType,
|
|
Metadata: metadata,
|
|
}
|
|
|
|
p.SetID()
|
|
|
|
return p
|
|
}
|
|
|
|
func packageURL(m pkg.DartPubMetadata) string {
|
|
var qualifiers packageurl.Qualifiers
|
|
|
|
if m.HostedURL != "" {
|
|
qualifiers = append(qualifiers, packageurl.Qualifier{
|
|
Key: "hosted_url",
|
|
Value: m.HostedURL,
|
|
})
|
|
} else if m.VcsURL != "" { // Default to using Hosted if somehow both are provided
|
|
qualifiers = append(qualifiers, packageurl.Qualifier{
|
|
Key: "vcs_url",
|
|
Value: m.VcsURL,
|
|
})
|
|
}
|
|
|
|
return packageurl.NewPackageURL(
|
|
packageurl.TypePub,
|
|
"",
|
|
m.Name,
|
|
m.Version,
|
|
qualifiers,
|
|
"",
|
|
).ToString()
|
|
}
|