mirror of
https://github.com/anchore/syft.git
synced 2026-03-30 05:33:24 +02:00
fix(java): improve lz4 detection (#4642)
Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@surgut.co.uk> Signed-off-by: Keith Zantow <kzantow@gmail.com> Co-authored-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
parent
db76d85d51
commit
35278f3d3d
@ -302,7 +302,11 @@ func GetManifestFieldGroupIDs(manifest *pkg.JavaManifest, fields []string) (grou
|
|||||||
}
|
}
|
||||||
|
|
||||||
func cleanGroupID(groupID string) string {
|
func cleanGroupID(groupID string) string {
|
||||||
return strings.TrimSpace(strings.Split(removeOSCIDirectives(groupID), "#")[0])
|
groupID = strings.TrimSpace(strings.Split(removeOSCIDirectives(groupID), "#")[0])
|
||||||
|
if replacement, ok := GroupIDCorrections[groupID]; ok {
|
||||||
|
return replacement
|
||||||
|
}
|
||||||
|
return groupID
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeOSCIDirectives(groupID string) string {
|
func removeOSCIDirectives(groupID string) string {
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
package cpegenerate
|
package cpegenerate
|
||||||
|
|
||||||
|
var GroupIDCorrections = map[string]string{
|
||||||
|
"org.lz4.java": "org.lz4",
|
||||||
|
}
|
||||||
|
|
||||||
var DefaultArtifactIDToGroupID = map[string]string{
|
var DefaultArtifactIDToGroupID = map[string]string{
|
||||||
"ant": "org.apache.ant",
|
"ant": "org.apache.ant",
|
||||||
"ant-antlr": "org.apache.ant",
|
"ant-antlr": "org.apache.ant",
|
||||||
|
|||||||
@ -183,6 +183,22 @@ func Test_groupIDsFromJavaPackage(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expects: []string{"io.jenkins-ci.plugin.thing"},
|
expects: []string{"io.jenkins-ci.plugin.thing"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "groupId correction properly applied",
|
||||||
|
pkg: pkg.Package{
|
||||||
|
Metadata: pkg.JavaArchive{
|
||||||
|
Manifest: &pkg.JavaManifest{
|
||||||
|
Main: pkg.KeyValues{
|
||||||
|
{
|
||||||
|
Key: "Automatic-Module-Name",
|
||||||
|
Value: "org.lz4.java",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expects: []string{"org.lz4"},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "from main Extension-Name field",
|
name: "from main Extension-Name field",
|
||||||
pkg: pkg.Package{
|
pkg: pkg.Package{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user