forked from anchore/syft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: don't validate pom declared group (anchore#2054)
Signed-off-by: Will Murphy <[email protected]>
- Loading branch information
1 parent
a3d6555
commit 5a90af1
Showing
2 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,12 @@ import ( | |
|
||
func Test_packageURL(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
pkg pkg.Package | ||
expect string | ||
}{ | ||
{ | ||
name: "maven", | ||
pkg: pkg.Package{ | ||
Name: "example-java-app-maven", | ||
Version: "0.1.0", | ||
|
@@ -38,6 +40,90 @@ func Test_packageURL(t *testing.T) { | |
}, | ||
expect: "pkg:maven/org.anchore/[email protected]", | ||
}, | ||
{ | ||
name: "POM properties have explicit group ID without . in it", | ||
pkg: pkg.Package{ | ||
Name: "example-java-app-maven", | ||
Version: "0.1.0", | ||
Language: pkg.Java, | ||
Type: pkg.JavaPkg, | ||
MetadataType: pkg.JavaMetadataType, | ||
Metadata: pkg.JavaMetadata{ | ||
VirtualPath: "test-fixtures/java-builds/packages/example-java-app-maven-0.1.0.jar", | ||
Manifest: &pkg.JavaManifest{ | ||
Main: map[string]string{ | ||
"Manifest-Version": "1.0", | ||
}, | ||
}, | ||
PomProperties: &pkg.PomProperties{ | ||
Path: "META-INF/maven/org.anchore/example-java-app-maven/pom.properties", | ||
GroupID: "commons", | ||
ArtifactID: "example-java-app-maven", | ||
Version: "0.1.0", | ||
Extra: make(map[string]string), | ||
}, | ||
}, | ||
}, | ||
expect: "pkg:maven/commons/[email protected]", | ||
}, | ||
{ | ||
name: "POM project has explicit group ID without . in it", | ||
pkg: pkg.Package{ | ||
Name: "example-java-app-maven", | ||
Version: "0.1.0", | ||
Language: pkg.Java, | ||
Type: pkg.JavaPkg, | ||
MetadataType: pkg.JavaMetadataType, | ||
Metadata: pkg.JavaMetadata{ | ||
VirtualPath: "test-fixtures/java-builds/packages/example-java-app-maven-0.1.0.jar", | ||
Manifest: &pkg.JavaManifest{ | ||
Main: map[string]string{ | ||
"Manifest-Version": "1.0", | ||
}, | ||
}, | ||
PomProperties: &pkg.PomProperties{ | ||
Path: "META-INF/maven/org.anchore/example-java-app-maven/pom.properties", | ||
ArtifactID: "example-java-app-maven", | ||
Version: "0.1.0", | ||
Extra: make(map[string]string), | ||
}, | ||
PomProject: &pkg.PomProject{ | ||
GroupID: "commons", | ||
}, | ||
}, | ||
}, | ||
expect: "pkg:maven/commons/[email protected]", | ||
}, | ||
{ | ||
name: "POM project has explicit group ID without . in it", | ||
pkg: pkg.Package{ | ||
Name: "example-java-app-maven", | ||
Version: "0.1.0", | ||
Language: pkg.Java, | ||
Type: pkg.JavaPkg, | ||
MetadataType: pkg.JavaMetadataType, | ||
Metadata: pkg.JavaMetadata{ | ||
VirtualPath: "test-fixtures/java-builds/packages/example-java-app-maven-0.1.0.jar", | ||
Manifest: &pkg.JavaManifest{ | ||
Main: map[string]string{ | ||
"Manifest-Version": "1.0", | ||
}, | ||
}, | ||
PomProperties: &pkg.PomProperties{ | ||
Path: "META-INF/maven/org.anchore/example-java-app-maven/pom.properties", | ||
ArtifactID: "example-java-app-maven", | ||
Version: "0.1.0", | ||
Extra: make(map[string]string), | ||
}, | ||
PomProject: &pkg.PomProject{ | ||
Parent: &pkg.PomParent{ | ||
GroupID: "parent", | ||
}, | ||
}, | ||
}, | ||
}, | ||
expect: "pkg:maven/parent/[email protected]", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.expect, func(t *testing.T) { | ||
|