mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 16:06:36 +01:00
Add dart support (#919)
Co-authored-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
co-authored by
Alex Goodman
parent
f157d7a862
commit
cb3e73e308
@@ -0,0 +1,38 @@
|
||||
package pkg
|
||||
|
||||
import (
|
||||
"github.com/anchore/packageurl-go"
|
||||
"github.com/anchore/syft/syft/linux"
|
||||
)
|
||||
|
||||
type DartPubMetadata struct {
|
||||
Name string `mapstructure:"name" json:"name"`
|
||||
Version string `mapstructure:"version" json:"version"`
|
||||
HostedURL string `mapstructure:"hosted_url" json:"hosted_url,omitempty"`
|
||||
VcsURL string `mapstructure:"vcs_url" json:"vcs_url,omitempty"`
|
||||
}
|
||||
|
||||
func (m DartPubMetadata) PackageURL(_ *linux.Release) 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()
|
||||
}
|
||||
Reference in New Issue
Block a user