mirror of
https://github.com/anchore/syft.git
synced 2025-11-21 18:33:18 +01:00
this PR makes the following changes to update the underlying license model to have more expressive capabilities it also provides some guarantee's surrounding the license values themselves - Licenses are updated from string -> pkg.LicenseSet which contain pkg.License with the following fields: - original `Value` read by syft - If it's possible to construct licenses will always have a valid SPDX expression for downstream consumption - the above is run against a generated list of SPDX license ID to try and find the correct ID - SPDX concluded vs declared is added to the new struct - URL source for license is added to the new struct - Location source is added to the new struct to show where the expression was pulled from
75 lines
2.3 KiB
Go
75 lines
2.3 KiB
Go
package pkg
|
|
|
|
import (
|
|
"sort"
|
|
|
|
"github.com/scylladb/go-set/strset"
|
|
)
|
|
|
|
var _ FileOwner = (*PythonPackageMetadata)(nil)
|
|
|
|
// PythonFileDigest represents the file metadata for a single file attributed to a python package.
|
|
type PythonFileDigest struct {
|
|
Algorithm string `json:"algorithm"`
|
|
Value string `json:"value"`
|
|
}
|
|
|
|
// PythonFileRecord represents a single entry within a RECORD file for a python wheel or egg package
|
|
type PythonFileRecord struct {
|
|
Path string `json:"path"`
|
|
Digest *PythonFileDigest `json:"digest,omitempty"`
|
|
Size string `json:"size,omitempty"`
|
|
}
|
|
|
|
type PythonDirectURLOriginInfo struct {
|
|
URL string `json:"url"`
|
|
CommitID string `json:"commitId,omitempty"`
|
|
VCS string `json:"vcs,omitempty"`
|
|
}
|
|
|
|
// PythonPackageMetadata represents all captured data for a python egg or wheel package.
|
|
type PythonPackageMetadata struct {
|
|
Name string `json:"name" mapstruct:"Name"`
|
|
Version string `json:"version" mapstruct:"Version"`
|
|
Author string `json:"author" mapstruct:"Author"`
|
|
AuthorEmail string `json:"authorEmail" mapstruct:"Authoremail"`
|
|
Platform string `json:"platform" mapstruct:"Platform"`
|
|
Files []PythonFileRecord `json:"files,omitempty"`
|
|
SitePackagesRootPath string `json:"sitePackagesRootPath"`
|
|
TopLevelPackages []string `json:"topLevelPackages,omitempty"`
|
|
DirectURLOrigin *PythonDirectURLOriginInfo `json:"directUrlOrigin,omitempty"`
|
|
}
|
|
|
|
type DirectURLOrigin struct {
|
|
URL string `json:"url"`
|
|
VCSInfo VCSInfo `json:"vcs_info"`
|
|
ArchiveInfo ArchiveInfo `json:"archive_info"`
|
|
DirInfo DirInfo `json:"dir_info"`
|
|
}
|
|
|
|
type DirInfo struct {
|
|
Editable bool `json:"editable"`
|
|
}
|
|
|
|
type ArchiveInfo struct {
|
|
Hash string `json:"hash"`
|
|
}
|
|
|
|
type VCSInfo struct {
|
|
CommitID string `json:"commit_id"`
|
|
VCS string `json:"vcs"`
|
|
RequestedRevision string `json:"requested_revision"`
|
|
}
|
|
|
|
func (m PythonPackageMetadata) OwnedFiles() (result []string) {
|
|
s := strset.New()
|
|
for _, f := range m.Files {
|
|
if f.Path != "" {
|
|
s.Add(f.Path)
|
|
}
|
|
}
|
|
result = s.List()
|
|
sort.Strings(result)
|
|
return result
|
|
}
|