From 0567206b384730e5e76a45c0d01a57fb2638d31e Mon Sep 17 00:00:00 2001 From: Samuel Dacanay Date: Tue, 15 Sep 2020 08:47:51 -0700 Subject: [PATCH] Change kebab case to camelCase in json keys throughout app Signed-off-by: Samuel Dacanay --- schema/json/schema.json | 138 +++++++++--------- syft/pkg/apk_metadata.go | 14 +- syft/pkg/java_metadata.go | 26 ++-- syft/pkg/package.go | 2 +- syft/pkg/rpm_metadata.go | 2 +- syft/presenter/json/artifact.go | 2 +- syft/presenter/json/image.go | 4 +- syft/presenter/json/location.go | 2 +- .../snapshot/TestJsonDirsPresenter.golden | 4 +- .../snapshot/TestJsonImgsPresenter.golden | 16 +- 10 files changed, 105 insertions(+), 105 deletions(-) diff --git a/schema/json/schema.json b/schema/json/schema.json index df1dee8fc..d8f07eb1a 100644 --- a/schema/json/schema.json +++ b/schema/json/schema.json @@ -4,7 +4,7 @@ "artifacts": { "items": { "properties": { - "found-by": { + "foundBy": { "items": { "type": "string" }, @@ -18,7 +18,7 @@ }, { "properties": { - "layer-index": { + "layerIndex": { "type": "integer" }, "path": { @@ -26,7 +26,7 @@ } }, "required": [ - "layer-index", + "layerIndex", "path" ], "type": "object" @@ -52,10 +52,10 @@ "checksum": { "type": "string" }, - "owner-gid": { + "ownerGid": { "type": "string" }, - "owner-uid": { + "ownerUid": { "type": "string" }, "path": { @@ -67,8 +67,8 @@ }, "required": [ "checksum", - "owner-gid", - "owner-uid", + "ownerGid", + "ownerUid", "path", "permissions" ], @@ -76,10 +76,10 @@ }, "type": "array" }, - "git-commit-of-apk-port": { + "gitCommitOfApkPort": { "type": "string" }, - "installed-size": { + "installedSize": { "type": "integer" }, "license": { @@ -95,7 +95,7 @@ }, { "properties": { - "extra-fields": { + "extraFields": { "properties": { "Archiver-Version": { "type": "string" @@ -160,60 +160,60 @@ ], "type": "object" }, - "implementation-title": { + "implementationTitle": { "type": "string" }, - "implementation-vendor": { + "implementationVendor": { "type": "string" }, - "implementation-version": { + "implementationVersion": { "type": "string" }, - "manifest-version": { + "manifestVersion": { "type": "string" }, "name": { "type": "string" }, - "specification-title": { + "specificationTitle": { "type": "string" }, - "specification-vendor": { + "specificationVendor": { "type": "string" }, - "specification-version": { + "specificationVersion": { "type": "string" } }, "required": [ - "extra-fields", - "implementation-title", - "implementation-vendor", - "implementation-version", - "manifest-version", + "extraFields", + "implementationTitle", + "implementationVendor", + "implementationVersion", + "manifestVersion", "name", - "specification-title", - "specification-vendor", - "specification-version" + "specificationTitle", + "specificationVendor", + "specificationVersion" ], "type": "object" } ] }, - "origin-package": { + "originPackage": { "type": "string" }, "package": { "type": "string" }, - "parent-package": { + "parentPackage": { "anyOf": [ { "type": "null" }, { "properties": { - "found-by": { + "foundBy": { "type": "string" }, "language": { @@ -229,7 +229,7 @@ "properties": { "manifest": { "properties": { - "extra-fields": { + "extraFields": { "properties": { "Archiver-Version": { "type": "string" @@ -294,59 +294,59 @@ ], "type": "object" }, - "implementation-title": { + "implementationTitle": { "type": "string" }, - "implementation-vendor": { + "implementationVendor": { "type": "string" }, - "implementation-version": { + "implementationVersion": { "type": "string" }, - "manifest-version": { + "manifestVersion": { "type": "string" }, "name": { "type": "string" }, - "specification-title": { + "specificationTitle": { "type": "string" }, - "specification-vendor": { + "specificationVendor": { "type": "string" }, - "specification-version": { + "specificationVersion": { "type": "string" } }, "required": [ - "extra-fields", - "implementation-title", - "implementation-vendor", - "implementation-version", - "manifest-version", + "extraFields", + "implementationTitle", + "implementationVendor", + "implementationVersion", + "manifestVersion", "name", - "specification-title", - "specification-vendor", - "specification-version" + "specificationTitle", + "specificationVendor", + "specificationVersion" ], "type": "object" }, - "parent-package": { + "parentPackage": { "type": "null" }, - "pom-properties": { + "pomProperties": { "properties": { "Path": { "type": "string" }, - "artifact-id": { + "artifactId": { "type": "string" }, - "extra-fields": { + "extraFields": { "type": "null" }, - "group-id": { + "groupId": { "type": "string" }, "name": { @@ -358,9 +358,9 @@ }, "required": [ "Path", - "artifact-id", - "extra-fields", - "group-id", + "artifactId", + "extraFields", + "groupId", "name", "version" ], @@ -369,8 +369,8 @@ }, "required": [ "manifest", - "parent-package", - "pom-properties" + "parentPackage", + "pomProperties" ], "type": "object" }, @@ -385,7 +385,7 @@ } }, "required": [ - "found-by", + "foundBy", "language", "licenses", "manifest", @@ -398,18 +398,18 @@ } ] }, - "pom-properties": { + "pomProperties": { "properties": { "Path": { "type": "string" }, - "artifact-id": { + "artifactId": { "type": "string" }, - "extra-fields": { + "extraFields": { "type": "null" }, - "group-id": { + "groupId": { "type": "string" }, "name": { @@ -421,18 +421,18 @@ }, "required": [ "Path", - "artifact-id", - "extra-fields", - "group-id", + "artifactId", + "extraFields", + "groupId", "name", "version" ], "type": "object" }, - "pull-checksum": { + "pullChecksum": { "type": "string" }, - "pull-dependencies": { + "pullDependencies": { "type": "string" }, "release": { @@ -464,7 +464,7 @@ } }, "required": [ - "found-by", + "foundBy", "locations", "name", "type", @@ -488,7 +488,7 @@ "digest": { "type": "string" }, - "media-type": { + "mediaType": { "type": "string" }, "size": { @@ -497,14 +497,14 @@ }, "required": [ "digest", - "media-type", + "mediaType", "size" ], "type": "object" }, "type": "array" }, - "media-type": { + "mediaType": { "type": "string" }, "size": { @@ -520,7 +520,7 @@ "required": [ "digest", "layers", - "media-type", + "mediaType", "size", "tags" ], diff --git a/syft/pkg/apk_metadata.go b/syft/pkg/apk_metadata.go index c3606701f..1acbca244 100644 --- a/syft/pkg/apk_metadata.go +++ b/syft/pkg/apk_metadata.go @@ -7,7 +7,7 @@ import ( // ApkMetadata represents all captured data for a Alpine DB package entry. See https://wiki.alpinelinux.org/wiki/Apk_spec for more information. type ApkMetadata struct { Package string `mapstructure:"P" json:"package"` - OriginPackage string `mapstructure:"o" json:"origin-package"` + OriginPackage string `mapstructure:"o" json:"originPackage"` Maintainer string `mapstructure:"m" json:"maintainer"` Version string `mapstructure:"V" json:"version"` License string `mapstructure:"L" json:"license"` @@ -15,18 +15,18 @@ type ApkMetadata struct { URL string `mapstructure:"U" json:"url"` Description string `mapstructure:"T" json:"description"` Size int `mapstructure:"S" json:"size"` - InstalledSize int `mapstructure:"I" json:"installed-size"` - PullDependencies string `mapstructure:"D" json:"pull-dependencies"` - PullChecksum string `mapstructure:"C" json:"pull-checksum"` - GitCommitOfAport string `mapstructure:"c" json:"git-commit-of-apk-port"` + InstalledSize int `mapstructure:"I" json:"installedSize"` + PullDependencies string `mapstructure:"D" json:"pullDependencies"` + PullChecksum string `mapstructure:"C" json:"pullChecksum"` + GitCommitOfAport string `mapstructure:"c" json:"gitCommitOfApkPort"` Files []ApkFileRecord `json:"files"` } // ApkFileRecord represents a single file listing and metadata from a APK DB entry (which may have many of these file records). type ApkFileRecord struct { Path string `json:"path"` - OwnerUID string `json:"owner-uid"` - OwnerGUI string `json:"owner-gid"` + OwnerUID string `json:"ownerUid"` + OwnerGUI string `json:"ownerGid"` Permissions string `json:"permissions"` Checksum string `json:"checksum"` } diff --git a/syft/pkg/java_metadata.go b/syft/pkg/java_metadata.go index 16947002d..01372ca68 100644 --- a/syft/pkg/java_metadata.go +++ b/syft/pkg/java_metadata.go @@ -5,31 +5,31 @@ import "github.com/package-url/packageurl-go" // JavaMetadata encapsulates all Java ecosystem metadata for a package as well as an (optional) parent relationship. type JavaMetadata struct { Manifest *JavaManifest `mapstructure:"Manifest" json:"manifest"` - PomProperties *PomProperties `mapstructure:"PomProperties" json:"pom-properties"` - Parent *Package `json:"parent-package"` // TODO: should this be included in the json output? + PomProperties *PomProperties `mapstructure:"PomProperties" json:"pomProperties"` + Parent *Package `json:"parentPackage"` // TODO: should this be included in the json output? } // PomProperties represents the fields of interest extracted from a Java archive's pom.xml file. type PomProperties struct { Path string Name string `mapstructure:"name" json:"name"` - GroupID string `mapstructure:"groupId" json:"group-id"` - ArtifactID string `mapstructure:"artifactId" json:"artifact-id"` + GroupID string `mapstructure:"groupId" json:"groupId"` + ArtifactID string `mapstructure:"artifactId" json:"artifactId"` Version string `mapstructure:"version" json:"version"` - Extra map[string]string `mapstructure:",remain" json:"extra-fields"` + Extra map[string]string `mapstructure:",remain" json:"extraFields"` } // JavaManifest represents the fields of interest extracted from a Java archive's META-INF/MANIFEST.MF file. type JavaManifest struct { Name string `mapstructure:"Name" json:"name"` - ManifestVersion string `mapstructure:"Manifest-Version" json:"manifest-version"` - SpecTitle string `mapstructure:"Specification-Title" json:"specification-title"` - SpecVersion string `mapstructure:"Specification-Version" json:"specification-version"` - SpecVendor string `mapstructure:"Specification-Vendor" json:"specification-vendor"` - ImplTitle string `mapstructure:"Implementation-Title" json:"implementation-title"` - ImplVersion string `mapstructure:"Implementation-Version" json:"implementation-version"` - ImplVendor string `mapstructure:"Implementation-Vendor" json:"implementation-vendor"` - Extra map[string]string `mapstructure:",remain" json:"extra-fields"` + ManifestVersion string `mapstructure:"Manifest-Version" json:"manifestVersion"` + SpecTitle string `mapstructure:"Specification-Title" json:"specificationTitle"` + SpecVersion string `mapstructure:"Specification-Version" json:"specificationVersion"` + SpecVendor string `mapstructure:"Specification-Vendor" json:"specificationVendor"` + ImplTitle string `mapstructure:"Implementation-Title" json:"implementationTitle"` + ImplVersion string `mapstructure:"Implementation-Version" json:"implementationVersion"` + ImplVendor string `mapstructure:"Implementation-Vendor" json:"implementationVendor"` + Extra map[string]string `mapstructure:",remain" json:"extraFields"` } func (m JavaMetadata) PackageURL() string { diff --git a/syft/pkg/package.go b/syft/pkg/package.go index 8a7bb0b13..c84b26fb5 100644 --- a/syft/pkg/package.go +++ b/syft/pkg/package.go @@ -20,7 +20,7 @@ type Package struct { id ID // uniquely identifies a package, set by the cataloger Name string `json:"manifest"` // the package name Version string `json:"version"` // the version of the package - FoundBy string `json:"found-by"` // the specific cataloger that discovered this package + FoundBy string `json:"foundBy"` // the specific cataloger that discovered this package Source []file.Reference `json:"sources"` // the locations that lead to the discovery of this package (note: this is not necessarily the locations that make up this package) // TODO: should we move licenses into metadata? Licenses []string `json:"licenses"` // licenses discovered with the package metadata diff --git a/syft/pkg/rpm_metadata.go b/syft/pkg/rpm_metadata.go index 63af04198..fed840d1b 100644 --- a/syft/pkg/rpm_metadata.go +++ b/syft/pkg/rpm_metadata.go @@ -14,7 +14,7 @@ type RpmMetadata struct { Epoch int `json:"epoch"` Arch string `json:"architecture"` Release string `json:"release"` - SourceRpm string `json:"source-rpm"` + SourceRpm string `json:"sourceRpm"` Size int `json:"size"` License string `json:"license"` Vendor string `json:"vendor"` diff --git a/syft/presenter/json/artifact.go b/syft/presenter/json/artifact.go index c4a218c77..f6157015e 100644 --- a/syft/presenter/json/artifact.go +++ b/syft/presenter/json/artifact.go @@ -9,7 +9,7 @@ type Artifact struct { Name string `json:"name"` Version string `json:"version"` Type string `json:"type"` - FoundBy []string `json:"found-by"` + FoundBy []string `json:"foundBy"` Locations Locations `json:"locations,omitempty"` Metadata interface{} `json:"metadata,omitempty"` } diff --git a/syft/presenter/json/image.go b/syft/presenter/json/image.go index a40aa1183..22e6eb3cf 100644 --- a/syft/presenter/json/image.go +++ b/syft/presenter/json/image.go @@ -6,12 +6,12 @@ type Image struct { Layers []Layer `json:"layers"` Size int64 `json:"size"` Digest string `json:"digest"` - MediaType string `json:"media-type"` + MediaType string `json:"mediaType"` Tags []string `json:"tags"` } type Layer struct { - MediaType string `json:"media-type"` + MediaType string `json:"mediaType"` Digest string `json:"digest"` Size int64 `json:"size"` } diff --git a/syft/presenter/json/location.go b/syft/presenter/json/location.go index 19f1cbb31..1987ec297 100644 --- a/syft/presenter/json/location.go +++ b/syft/presenter/json/location.go @@ -11,7 +11,7 @@ type Locations interface{} type ImageLocation struct { Path string `json:"path"` - LayerIndex uint `json:"layer-index"` + LayerIndex uint `json:"layerIndex"` } func NewLocations(p *pkg.Package, s scope.Scope) (Locations, error) { diff --git a/syft/presenter/json/test-fixtures/snapshot/TestJsonDirsPresenter.golden b/syft/presenter/json/test-fixtures/snapshot/TestJsonDirsPresenter.golden index fafcf58eb..45fb1c47d 100644 --- a/syft/presenter/json/test-fixtures/snapshot/TestJsonDirsPresenter.golden +++ b/syft/presenter/json/test-fixtures/snapshot/TestJsonDirsPresenter.golden @@ -4,7 +4,7 @@ "name": "package-1", "version": "1.0.1", "type": "deb", - "found-by": [ + "foundBy": [ "the-cataloger-1" ], "locations": [ @@ -15,7 +15,7 @@ "name": "package-2", "version": "2.0.1", "type": "deb", - "found-by": [ + "foundBy": [ "the-cataloger-2" ], "locations": [ diff --git a/syft/presenter/json/test-fixtures/snapshot/TestJsonImgsPresenter.golden b/syft/presenter/json/test-fixtures/snapshot/TestJsonImgsPresenter.golden index 15d20cb52..61219a823 100644 --- a/syft/presenter/json/test-fixtures/snapshot/TestJsonImgsPresenter.golden +++ b/syft/presenter/json/test-fixtures/snapshot/TestJsonImgsPresenter.golden @@ -4,13 +4,13 @@ "name": "package-1", "version": "1.0.1", "type": "deb", - "found-by": [ + "foundBy": [ "the-cataloger-1" ], "locations": [ { "path": "/somefile-1.txt", - "layer-index": 0 + "layerIndex": 0 } ] }, @@ -18,13 +18,13 @@ "name": "package-2", "version": "2.0.1", "type": "deb", - "found-by": [ + "foundBy": [ "the-cataloger-2" ], "locations": [ { "path": "/somefile-2.txt", - "layer-index": 1 + "layerIndex": 1 } ] } @@ -32,24 +32,24 @@ "image": { "layers": [ { - "media-type": "application/vnd.docker.image.rootfs.diff.tar.gzip", + "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "digest": "sha256:056c0789fa9ad629ceae6d09713fb035f84115af3c4a88a43aa60f13bc683053", "size": 22 }, { - "media-type": "application/vnd.docker.image.rootfs.diff.tar.gzip", + "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "digest": "sha256:b461c48116592c570a66fed71d5b09662a8172e168b7938cf317af47872cdc9b", "size": 16 }, { - "media-type": "application/vnd.docker.image.rootfs.diff.tar.gzip", + "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "digest": "sha256:00b80053e05c01da485015610d288ce3185fac00d251e2ada02b45a7a7c5f589", "size": 27 } ], "size": 65, "digest": "sha256:3c53d2d891940f8d8e95acb77b58752f54dc5de9d91d19dd90ced2db76256cea", - "media-type": "application/vnd.docker.distribution.manifest.v2+json", + "mediaType": "application/vnd.docker.distribution.manifest.v2+json", "tags": [ "anchore-fixture-image-simple:04e16e44161c8888a1a963720fd0443cbf7eef8101434c431de8725cd98cc9f7" ]