fix: deterministic java purls (#2170)

Previously, which PURL was generated depended on the order of key iteration
in maps. Also update an integ test that was apparently only passing because
of the previous issue.

Signed-off-by: Will Murphy <will.murphy@anchore.com>
This commit is contained in:
William Murphy
2023-09-25 09:28:18 -04:00
committed by GitHub
parent 8314c0d2cb
commit e34adea749
3 changed files with 6 additions and 3 deletions
+2
View File
@@ -1,6 +1,7 @@
package cpe
import (
"sort"
"strings"
"github.com/scylladb/go-set/strset"
@@ -287,6 +288,7 @@ func GetManifestFieldGroupIDs(manifest *pkg.JavaManifest, fields []string) (grou
}
}
}
sort.Strings(groupIDs)
return groupIDs
}
@@ -37,6 +37,7 @@ var DefaultArtifactIDToGroupID = map[string]string{
"ant-weblogic": "org.apache.ant",
"ant-xz": "org.apache.ant",
"commons-codec": "commons-codec",
"commons-logging": "commons-logging", // see e.g. https://mvnrepository.com/artifact/commons-logging/commons-logging/1.1.1
"okhttp": "com.squareup.okhttp3",
"okio": "com.squareup.okio",
"spring": "org.springframework",