diff --git a/syft/format/syftjson/model/document.go b/syft/format/syftjson/model/document.go index a9886ba4b..87c4b3761 100644 --- a/syft/format/syftjson/model/document.go +++ b/syft/format/syftjson/model/document.go @@ -2,13 +2,13 @@ package model // Document represents the syft cataloging findings as a JSON document type Document struct { - Artifacts []Package `json:"artifacts"` // Artifacts is the list of packages discovered and placed into the catalog - ArtifactRelationships []Relationship `json:"artifactRelationships"` - Files []File `json:"files,omitempty"` // note: must have omitempty - Source Source `json:"source"` // Source represents the original object that was cataloged - Distro LinuxRelease `json:"distro"` // Distro represents the Linux distribution that was detected from the source - Descriptor Descriptor `json:"descriptor"` // Descriptor is a block containing self-describing information about syft - Schema Schema `json:"schema"` // Schema is a block reserved for defining the version for the shape of this JSON document and where to find the schema document to validate the shape + Schema Schema `json:"schema"` // Schema is a block reserved for defining the version for the shape of this JSON document and where to find the schema document to validate the shape + Descriptor Descriptor `json:"descriptor"` // Descriptor is a block containing self-describing information about syft + Source Source `json:"source"` // Source represents the original object that was cataloged + Distro LinuxRelease `json:"distro"` // Distro represents the Linux distribution that was detected from the source + Packages []Package `json:"packages"` // Packages is the list of packages discovered + Relationships []Relationship `json:"relationships"` // Relationships is a list of package-to-package, package-to-file, and file-to-package relationships + Files []File `json:"files,omitempty"` // Files is a list of all files at their real path and any associated metadata about that file } // Descriptor describes what created the document as well as surrounding metadata diff --git a/syft/format/syftjson/to_format_model.go b/syft/format/syftjson/to_format_model.go index a05b17bfa..ce0e02483 100644 --- a/syft/format/syftjson/to_format_model.go +++ b/syft/format/syftjson/to_format_model.go @@ -35,12 +35,12 @@ func metadataType(metadata interface{}, legacy bool) string { // ToFormatModel transforms the sbom import a format-specific model. func ToFormatModel(s sbom.SBOM, cfg EncoderConfig) model.Document { return model.Document{ - Artifacts: toPackageModels(s.Artifacts.Packages, cfg), - ArtifactRelationships: toRelationshipModel(s.Relationships), - Files: toFile(s), - Source: toSourceModel(s.Source), - Distro: toLinuxReleaser(s.Artifacts.LinuxDistribution), - Descriptor: toDescriptor(s.Descriptor), + Packages: toPackageModels(s.Artifacts.Packages, cfg), + Relationships: toRelationshipModel(s.Relationships), + Files: toFile(s), + Source: toSourceModel(s.Source), + Distro: toLinuxReleaser(s.Artifacts.LinuxDistribution), + Descriptor: toDescriptor(s.Descriptor), Schema: model.Schema{ Version: internal.JSONSchemaVersion, URL: fmt.Sprintf("https://raw.githubusercontent.com/anchore/syft/main/schema/json/schema-%s.json", internal.JSONSchemaVersion), diff --git a/syft/format/syftjson/to_syft_model.go b/syft/format/syftjson/to_syft_model.go index 8807688e3..a904c3015 100644 --- a/syft/format/syftjson/to_syft_model.go +++ b/syft/format/syftjson/to_syft_model.go @@ -24,7 +24,7 @@ import ( func toSyftModel(doc model.Document) *sbom.SBOM { idAliases := make(map[string]string) - catalog := toSyftCatalog(doc.Artifacts, idAliases) + catalog := toSyftCatalog(doc.Packages, idAliases) fileArtifacts := toSyftFiles(doc.Files) @@ -39,7 +39,7 @@ func toSyftModel(doc model.Document) *sbom.SBOM { }, Source: *toSyftSourceData(doc.Source), Descriptor: toSyftDescriptor(doc.Descriptor), - Relationships: warnConversionErrors(toSyftRelationships(&doc, catalog, doc.ArtifactRelationships, idAliases)), + Relationships: warnConversionErrors(toSyftRelationships(&doc, catalog, doc.Relationships, idAliases)), } } diff --git a/syft/format/syftjson/to_syft_model_test.go b/syft/format/syftjson/to_syft_model_test.go index 7bbb604da..34d63ffc6 100644 --- a/syft/format/syftjson/to_syft_model_test.go +++ b/syft/format/syftjson/to_syft_model_test.go @@ -177,7 +177,7 @@ func Test_idsHaveChanged(t *testing.T) { Type: "file", Metadata: source.FileSourceMetadata{Path: "some/path"}, }, - Artifacts: []model.Package{ + Packages: []model.Package{ { PackageBasicData: model.PackageBasicData{ ID: "1", @@ -191,7 +191,7 @@ func Test_idsHaveChanged(t *testing.T) { }, }, }, - ArtifactRelationships: []model.Relationship{ + Relationships: []model.Relationship{ { Parent: "1", Child: "2", diff --git a/test/integration/java_purl_test.go b/test/integration/java_purl_test.go index 15ed6dd0d..a5c11e0ab 100644 --- a/test/integration/java_purl_test.go +++ b/test/integration/java_purl_test.go @@ -34,7 +34,7 @@ func TestJavaPURLs(t *testing.T) { // syft anchore/test_images:java-56d52bc -o template -t /tmp/test.templ | grep 'pkg:maven' | sort | uniq >> test/integration/java_purl_test.go // where the template is: /* -{{ range .Artifacts}}"{{.Name}}@{{.Version}}":"{{.PURL}}", +{{ range .Packages}}"{{.Name}}@{{.Version}}":"{{.PURL}}", {{ end }} */ // The map was then hand-edited for correctness by comparing to Maven Central. diff --git a/test/integration/package_ownership_relationship_test.go b/test/integration/package_ownership_relationship_test.go index d3ce07454..b9c6cc62a 100644 --- a/test/integration/package_ownership_relationship_test.go +++ b/test/integration/package_ownership_relationship_test.go @@ -37,7 +37,7 @@ func TestPackageOwnershipRelationships(t *testing.T) { t.Fatalf("unable to decode json doc: %+v", err) } - if len(doc.ArtifactRelationships) == 0 { + if len(doc.Relationships) == 0 { t.Errorf("expected to find relationships between packages but found none") }