update json schema and test for java virtualPath

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman 2020-10-28 15:23:56 -04:00
parent 76c8f24090
commit 8bcba7d830
No known key found for this signature in database
GPG Key ID: 5CB45AE22BAB7EA7
3 changed files with 21 additions and 10 deletions

View File

@ -376,9 +376,6 @@
}, },
"pomProperties": { "pomProperties": {
"properties": { "properties": {
"Path": {
"type": "string"
},
"artifactId": { "artifactId": {
"type": "string" "type": "string"
}, },
@ -391,25 +388,32 @@
"name": { "name": {
"type": "string" "type": "string"
}, },
"path": {
"type": "string"
},
"version": { "version": {
"type": "string" "type": "string"
} }
}, },
"required": [ "required": [
"Path",
"artifactId", "artifactId",
"extraFields", "extraFields",
"groupId", "groupId",
"name", "name",
"path",
"version" "version"
], ],
"type": "object" "type": "object"
},
"virtualPath": {
"type": "string"
} }
}, },
"required": [ "required": [
"manifest", "manifest",
"parentPackage", "parentPackage",
"pomProperties" "pomProperties",
"virtualPath"
], ],
"type": "object" "type": "object"
}, },
@ -446,9 +450,6 @@
}, },
"pomProperties": { "pomProperties": {
"properties": { "properties": {
"Path": {
"type": "string"
},
"artifactId": { "artifactId": {
"type": "string" "type": "string"
}, },
@ -461,16 +462,19 @@
"name": { "name": {
"type": "string" "type": "string"
}, },
"path": {
"type": "string"
},
"version": { "version": {
"type": "string" "type": "string"
} }
}, },
"required": [ "required": [
"Path",
"artifactId", "artifactId",
"extraFields", "extraFields",
"groupId", "groupId",
"name", "name",
"path",
"version" "version"
], ],
"type": "object" "type": "object"
@ -510,6 +514,9 @@
}, },
"version": { "version": {
"type": "string" "type": "string"
},
"virtualPath": {
"type": "string"
} }
}, },
"type": "object" "type": "object"

View File

@ -143,6 +143,7 @@ func TestParseJar(t *testing.T) {
Type: pkg.JenkinsPluginPkg, Type: pkg.JenkinsPluginPkg,
MetadataType: pkg.JavaMetadataType, MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{ Metadata: pkg.JavaMetadata{
VirtualPath: "test-fixtures/java-builds/packages/example-jenkins-plugin.hpi",
Manifest: &pkg.JavaManifest{ Manifest: &pkg.JavaManifest{
ManifestVersion: "1.0", ManifestVersion: "1.0",
SpecTitle: "The Jenkins Plugins Parent POM Project", SpecTitle: "The Jenkins Plugins Parent POM Project",
@ -188,6 +189,7 @@ func TestParseJar(t *testing.T) {
Type: pkg.JavaPkg, Type: pkg.JavaPkg,
MetadataType: pkg.JavaMetadataType, MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{ Metadata: pkg.JavaMetadata{
VirtualPath: "test-fixtures/java-builds/packages/example-java-app-gradle-0.1.0.jar",
Manifest: &pkg.JavaManifest{ Manifest: &pkg.JavaManifest{
ManifestVersion: "1.0", ManifestVersion: "1.0",
}, },
@ -208,6 +210,7 @@ func TestParseJar(t *testing.T) {
Type: pkg.JavaPkg, Type: pkg.JavaPkg,
MetadataType: pkg.JavaMetadataType, MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{ Metadata: pkg.JavaMetadata{
VirtualPath: "test-fixtures/java-builds/packages/example-java-app-maven-0.1.0.jar",
Manifest: &pkg.JavaManifest{ Manifest: &pkg.JavaManifest{
ManifestVersion: "1.0", ManifestVersion: "1.0",
Extra: map[string]string{ Extra: map[string]string{
@ -233,6 +236,7 @@ func TestParseJar(t *testing.T) {
Type: pkg.JavaPkg, Type: pkg.JavaPkg,
MetadataType: pkg.JavaMetadataType, MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{ Metadata: pkg.JavaMetadata{
VirtualPath: "test-fixtures/java-builds/packages/example-java-app-maven-0.1.0.jar",
PomProperties: &pkg.PomProperties{ PomProperties: &pkg.PomProperties{
Path: "META-INF/maven/joda-time/joda-time/pom.properties", Path: "META-INF/maven/joda-time/joda-time/pom.properties",
GroupID: "joda-time", GroupID: "joda-time",

View File

@ -4,7 +4,7 @@ import "github.com/package-url/packageurl-go"
// JavaMetadata encapsulates all Java ecosystem metadata for a package as well as an (optional) parent relationship. // JavaMetadata encapsulates all Java ecosystem metadata for a package as well as an (optional) parent relationship.
type JavaMetadata struct { type JavaMetadata struct {
VirtualPath string `json:"virtual-path"` VirtualPath string `json:"virtualPath"`
Manifest *JavaManifest `mapstructure:"Manifest" json:"manifest"` Manifest *JavaManifest `mapstructure:"Manifest" json:"manifest"`
PomProperties *PomProperties `mapstructure:"PomProperties" json:"pomProperties"` PomProperties *PomProperties `mapstructure:"PomProperties" json:"pomProperties"`
Parent *Package `json:"parentPackage"` // TODO: should this be included in the json output? Parent *Package `json:"parentPackage"` // TODO: should this be included in the json output?