From 24a2f9344b92d267bfbe2be3b713d0f6998819bd Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Thu, 22 Apr 2021 13:20:12 -0400 Subject: [PATCH] add additional string.contains case for jenkins package by group id Signed-off-by: Alex Goodman --- syft/pkg/java_metadata.go | 4 +++- syft/pkg/java_metadata_test.go | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/syft/pkg/java_metadata.go b/syft/pkg/java_metadata.go index bac1bc7a8..3036418a3 100644 --- a/syft/pkg/java_metadata.go +++ b/syft/pkg/java_metadata.go @@ -1,6 +1,8 @@ package pkg import ( + "strings" + "github.com/anchore/syft/internal" "github.com/package-url/packageurl-go" ) @@ -35,7 +37,7 @@ type PomProperties struct { // PkgTypeIndicated returns the package Type indicated by the data contained in the PomProperties. func (p PomProperties) PkgTypeIndicated() Type { - if internal.HasAnyOfPrefixes(p.GroupID, JenkinsPluginPomPropertiesGroupIDs...) { + if internal.HasAnyOfPrefixes(p.GroupID, JenkinsPluginPomPropertiesGroupIDs...) || strings.Contains(p.GroupID, ".jenkins.plugin") { return JenkinsPluginPkg } diff --git a/syft/pkg/java_metadata_test.go b/syft/pkg/java_metadata_test.go index 17781d254..8dcbded88 100644 --- a/syft/pkg/java_metadata_test.go +++ b/syft/pkg/java_metadata_test.go @@ -90,6 +90,17 @@ func TestPomProperties_PkgTypeIndicated(t *testing.T) { }, expectedType: JenkinsPluginPkg, }, + { + name: "jenkins.plugin somewhere in group id", + pomProperties: PomProperties{ + Path: "some path", + Name: "some name", + GroupID: "org.wagoodman.jenkins.plugins.something", + ArtifactID: "some artifact ID", + Version: "1", + }, + expectedType: JenkinsPluginPkg, + }, } for _, tc := range cases {