mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 07:56:36 +01:00
Remove MetadataType from core package object and normalize JSON metadataType values (#1983)
* [wip] Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * distinct the package metadata functions Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * remove metadata type from package core model Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * incorporate review feedback for names Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add RPM archive metadata and split parser helpers Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * clarify the python package metadata type Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * rename the KB metadata type Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * break hackage and composer types by use case Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * linting fix Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix encoding and decoding for syft-json and cyclonedx Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * bump json schema to 11 Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update cyclonedx-json snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update cyclonedx-xml snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update spdx-json snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update spdx-tv snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update syft-json snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * correct metadata type in stack yaml parser test Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix bom-ref redactor for cyclonedx-xml Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add tests for legacy package metadata names Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * regenerate json schema v11 Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix legacy HackageMetadataType reflect type value check Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix linting Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * packagemetadata discovery should account for type shadowing Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix linting Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix cli tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * bump json schema version to v12 Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update json schema to incorporate changes from main Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add syft-json legacy config option Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add tests around v11-v12 json decoding Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add docs for SYFT_JSON_LEGACY Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * rename structs to be compliant with new naming scheme Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
@@ -19,7 +19,7 @@ func NewInstalledGemSpecCataloger() *generic.Cataloger {
|
||||
WithParserByGlobs(parseGemSpecEntries, "**/specifications/**/*.gemspec")
|
||||
}
|
||||
|
||||
// NewGemSpecCataloger looks for gems with a broader scope.
|
||||
// NewGemSpecCataloger looks for gems without the additional requirement of the gem being installed.
|
||||
func NewGemSpecCataloger() *generic.Cataloger {
|
||||
return generic.NewCataloger("ruby-gemspec-cataloger").
|
||||
WithParserByGlobs(parseGemSpecEntries, "**/*.gemspec")
|
||||
|
||||
@@ -23,15 +23,14 @@ func newGemfileLockPackage(name, version string, locations ...file.Location) pkg
|
||||
|
||||
func newGemspecPackage(m gemData, gemSpecLocation file.Location) pkg.Package {
|
||||
p := pkg.Package{
|
||||
Name: m.Name,
|
||||
Version: m.Version,
|
||||
Locations: file.NewLocationSet(gemSpecLocation.WithAnnotation(pkg.EvidenceAnnotationKey, pkg.PrimaryEvidenceAnnotation)),
|
||||
Licenses: pkg.NewLicenseSet(pkg.NewLicensesFromLocation(gemSpecLocation, m.Licenses...)...),
|
||||
PURL: packageURL(m.Name, m.Version),
|
||||
Language: pkg.Ruby,
|
||||
Type: pkg.GemPkg,
|
||||
MetadataType: pkg.GemMetadataType,
|
||||
Metadata: m.GemMetadata,
|
||||
Name: m.Name,
|
||||
Version: m.Version,
|
||||
Locations: file.NewLocationSet(gemSpecLocation.WithAnnotation(pkg.EvidenceAnnotationKey, pkg.PrimaryEvidenceAnnotation)),
|
||||
Licenses: pkg.NewLicenseSet(pkg.NewLicensesFromLocation(gemSpecLocation, m.Licenses...)...),
|
||||
PURL: packageURL(m.Name, m.Version),
|
||||
Language: pkg.Ruby,
|
||||
Type: pkg.GemPkg,
|
||||
Metadata: m.RubyGemspec,
|
||||
}
|
||||
|
||||
p.SetID()
|
||||
|
||||
@@ -22,7 +22,7 @@ type postProcessor func(string) []string
|
||||
|
||||
type gemData struct {
|
||||
Licenses []string `mapstructure:"licenses" json:"licenses,omitempty"`
|
||||
pkg.GemMetadata `mapstructure:",squash" json:",inline"`
|
||||
pkg.RubyGemspec `mapstructure:",squash" json:",inline"`
|
||||
}
|
||||
|
||||
// match example: Al\u003Ex ---> 003E
|
||||
@@ -64,6 +64,7 @@ func processList(s string) []string {
|
||||
return results
|
||||
}
|
||||
|
||||
// parseGemFileLockEntries parses the gemfile.lock file and returns the packages and relationships found.
|
||||
func parseGemSpecEntries(_ file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
|
||||
var pkgs []pkg.Package
|
||||
var fields = make(map[string]interface{})
|
||||
|
||||
@@ -22,9 +22,8 @@ func TestParseGemspec(t *testing.T) {
|
||||
Licenses: pkg.NewLicenseSet(
|
||||
pkg.NewLicenseFromLocations("MIT", file.NewLocation(fixture)),
|
||||
),
|
||||
Language: pkg.Ruby,
|
||||
MetadataType: pkg.GemMetadataType,
|
||||
Metadata: pkg.GemMetadata{
|
||||
Language: pkg.Ruby,
|
||||
Metadata: pkg.RubyGemspec{
|
||||
Name: "bundler",
|
||||
Version: "2.1.4",
|
||||
Files: []string{"exe/bundle", "exe/bundler"},
|
||||
|
||||
Reference in New Issue
Block a user