Enhance CPE generation for java GroupId and filtering (#402)

* enhance cpe generation for group id and filtering

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* rename group id const + add doc comment for HasAnyOfPrefixes

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman
2021-04-22 12:22:56 +00:00
committed by GitHub
parent 0c29090b42
commit d9de63c837
9 changed files with 333 additions and 44 deletions
@@ -6,6 +6,7 @@ type testCase struct {
name string
pkgType pkg.Type
pkgLanguage pkg.Language
duplicates int
pkgInfo map[string]string
}
@@ -155,7 +156,6 @@ var commonTestCases = []testCase{
pkgLanguage: pkg.Java,
pkgInfo: map[string]string{
"example-java-app-maven": "0.1.0",
"example-jenkins-plugin": "1.0-SNAPSHOT", // the jenkins HPI file has a nested JAR of the same name
"joda-time": "2.9.2",
},
},
@@ -163,6 +163,7 @@ var commonTestCases = []testCase{
name: "find jenkins plugins",
pkgType: pkg.JenkinsPluginPkg,
pkgLanguage: pkg.Java,
duplicates: 1, // there is a "example-jenkins-plugin" HPI, and nested within that a JAR of the same name
pkgInfo: map[string]string{
"example-jenkins-plugin": "1.0-SNAPSHOT",
},
+2 -2
View File
@@ -96,7 +96,7 @@ func TestPkgCoverageImage(t *testing.T) {
pkgCount++
}
if pkgCount != len(c.pkgInfo) {
if pkgCount != len(c.pkgInfo)+c.duplicates {
t.Logf("Discovered packages of type %+v", c.pkgType)
for a := range catalog.Enumerate(c.pkgType) {
t.Log(" ", a)
@@ -175,7 +175,7 @@ func TestPkgCoverageDirectory(t *testing.T) {
actualPkgCount++
}
if actualPkgCount != len(test.pkgInfo) {
if actualPkgCount != len(test.pkgInfo)+test.duplicates {
for actualPkg := range catalog.Enumerate(test.pkgType) {
t.Log(" ", actualPkg)
}