mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
add jenkins filter for known bad CPE field combinations
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
parent
1b62b10b2b
commit
18af21d2a5
@ -37,14 +37,22 @@ var productCandidatesByPkgType = candidateStore{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var cpeFilters = []filterFn{
|
var cpeFilters = []filterFn{
|
||||||
// nolint: goconst
|
|
||||||
func(cpe pkg.CPE, p pkg.Package) bool {
|
func(cpe pkg.CPE, p pkg.Package) bool {
|
||||||
// jira / atlassian should not apply to clients
|
// jira / atlassian should not apply to clients
|
||||||
if cpe.Vendor == "atlassian" && cpe.Product == "jira" && strings.Contains(p.Name, "client") {
|
if cpe.Product == "jira" && strings.Contains(strings.ToLower(p.Name), "client") {
|
||||||
return true
|
if cpe.Vendor == wfn.Any || cpe.Vendor == "jira" || cpe.Vendor == "atlassian" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if cpe.Vendor == "jira" && cpe.Product == "jira" && strings.Contains(p.Name, "client") {
|
return false
|
||||||
return true
|
},
|
||||||
|
// nolint: goconst
|
||||||
|
func(cpe pkg.CPE, p pkg.Package) bool {
|
||||||
|
// jenkins server should only match against a product with the name jenkins
|
||||||
|
if cpe.Product == "jenkins" && !strings.Contains(strings.ToLower(p.Name), "jenkins") {
|
||||||
|
if cpe.Vendor == wfn.Any || cpe.Vendor == "jenkins" || cpe.Vendor == "cloudbees" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
@ -186,6 +194,9 @@ func candidateProducts(p pkg.Package) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func candidateProductsForJava(p pkg.Package) []string {
|
func candidateProductsForJava(p pkg.Package) []string {
|
||||||
|
// TODO: we could get group-id-like info from the MANIFEST.MF "Automatic-Module-Name" field
|
||||||
|
// for more info see pkg:maven/commons-io/commons-io@2.8.0 within cloudbees/cloudbees-core-mm:2.263.4.2
|
||||||
|
// at /usr/share/jenkins/jenkins.war:WEB-INF/plugins/analysis-model-api.hpi:WEB-INF/lib/commons-io-2.8.0.jar
|
||||||
if product, _ := productAndVendorFromPomPropertiesGroupID(p); product != "" {
|
if product, _ := productAndVendorFromPomPropertiesGroupID(p); product != "" {
|
||||||
// ignore group ID info from a jenkins plugin, as using this info may imply that this package
|
// ignore group ID info from a jenkins plugin, as using this info may imply that this package
|
||||||
// CPE belongs to the cloudbees org (or similar) which is wrong.
|
// CPE belongs to the cloudbees org (or similar) which is wrong.
|
||||||
|
|||||||
@ -351,9 +351,6 @@ func TestGeneratePackageCPEs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"cpe:2.3:a:*:jira:3.2:*:*:*:*:*:*:*",
|
|
||||||
"cpe:2.3:a:*:jira:3.2:*:*:*:*:java:*:*",
|
|
||||||
"cpe:2.3:a:*:jira:3.2:*:*:*:*:maven:*:*",
|
|
||||||
"cpe:2.3:a:*:jira_client_core:3.2:*:*:*:*:*:*:*",
|
"cpe:2.3:a:*:jira_client_core:3.2:*:*:*:*:*:*:*",
|
||||||
"cpe:2.3:a:*:jira_client_core:3.2:*:*:*:*:java:*:*",
|
"cpe:2.3:a:*:jira_client_core:3.2:*:*:*:*:java:*:*",
|
||||||
"cpe:2.3:a:*:jira_client_core:3.2:*:*:*:*:maven:*:*",
|
"cpe:2.3:a:*:jira_client_core:3.2:*:*:*:*:maven:*:*",
|
||||||
@ -371,6 +368,61 @@ func TestGeneratePackageCPEs(t *testing.T) {
|
|||||||
"cpe:2.3:a:jira_client_core:jira_client_core:3.2:*:*:*:*:maven:*:*",
|
"cpe:2.3:a:jira_client_core:jira_client_core:3.2:*:*:*:*:maven:*:*",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "jenkins filtering",
|
||||||
|
p: pkg.Package{
|
||||||
|
Name: "cloudbees-installation-manager",
|
||||||
|
Version: "2.89.0.33",
|
||||||
|
FoundBy: "some-analyzer",
|
||||||
|
Language: pkg.Java,
|
||||||
|
Type: pkg.JavaPkg,
|
||||||
|
MetadataType: pkg.JavaMetadataType,
|
||||||
|
Metadata: pkg.JavaMetadata{
|
||||||
|
PomProperties: &pkg.PomProperties{
|
||||||
|
GroupID: "com.cloudbees.jenkins.modules",
|
||||||
|
ArtifactID: "cloudbees-installation-manager",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expected: []string{
|
||||||
|
"cpe:2.3:a:*:cloudbees-installation-manager:2.89.0.33:*:*:*:*:*:*:*",
|
||||||
|
"cpe:2.3:a:*:cloudbees-installation-manager:2.89.0.33:*:*:*:*:java:*:*",
|
||||||
|
"cpe:2.3:a:*:cloudbees-installation-manager:2.89.0.33:*:*:*:*:maven:*:*",
|
||||||
|
"cpe:2.3:a:*:cloudbees_installation_manager:2.89.0.33:*:*:*:*:*:*:*",
|
||||||
|
"cpe:2.3:a:*:cloudbees_installation_manager:2.89.0.33:*:*:*:*:java:*:*",
|
||||||
|
"cpe:2.3:a:*:cloudbees_installation_manager:2.89.0.33:*:*:*:*:maven:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees-installation-manager:cloudbees-installation-manager:2.89.0.33:*:*:*:*:*:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees-installation-manager:cloudbees-installation-manager:2.89.0.33:*:*:*:*:java:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees-installation-manager:cloudbees-installation-manager:2.89.0.33:*:*:*:*:maven:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees-installation-manager:cloudbees_installation_manager:2.89.0.33:*:*:*:*:*:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees-installation-manager:cloudbees_installation_manager:2.89.0.33:*:*:*:*:java:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees-installation-manager:cloudbees_installation_manager:2.89.0.33:*:*:*:*:maven:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees-installation-manager:jenkins:2.89.0.33:*:*:*:*:*:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees-installation-manager:jenkins:2.89.0.33:*:*:*:*:java:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees-installation-manager:jenkins:2.89.0.33:*:*:*:*:maven:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees:cloudbees-installation-manager:2.89.0.33:*:*:*:*:*:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees:cloudbees-installation-manager:2.89.0.33:*:*:*:*:java:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees:cloudbees-installation-manager:2.89.0.33:*:*:*:*:maven:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees:cloudbees_installation_manager:2.89.0.33:*:*:*:*:*:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees:cloudbees_installation_manager:2.89.0.33:*:*:*:*:java:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees:cloudbees_installation_manager:2.89.0.33:*:*:*:*:maven:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees_installation_manager:cloudbees-installation-manager:2.89.0.33:*:*:*:*:*:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees_installation_manager:cloudbees-installation-manager:2.89.0.33:*:*:*:*:java:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees_installation_manager:cloudbees-installation-manager:2.89.0.33:*:*:*:*:maven:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees_installation_manager:cloudbees_installation_manager:2.89.0.33:*:*:*:*:*:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees_installation_manager:cloudbees_installation_manager:2.89.0.33:*:*:*:*:java:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees_installation_manager:cloudbees_installation_manager:2.89.0.33:*:*:*:*:maven:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees_installation_manager:jenkins:2.89.0.33:*:*:*:*:*:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees_installation_manager:jenkins:2.89.0.33:*:*:*:*:java:*:*",
|
||||||
|
"cpe:2.3:a:cloudbees_installation_manager:jenkins:2.89.0.33:*:*:*:*:maven:*:*",
|
||||||
|
"cpe:2.3:a:jenkins:cloudbees-installation-manager:2.89.0.33:*:*:*:*:*:*:*",
|
||||||
|
"cpe:2.3:a:jenkins:cloudbees-installation-manager:2.89.0.33:*:*:*:*:java:*:*",
|
||||||
|
"cpe:2.3:a:jenkins:cloudbees-installation-manager:2.89.0.33:*:*:*:*:maven:*:*",
|
||||||
|
"cpe:2.3:a:jenkins:cloudbees_installation_manager:2.89.0.33:*:*:*:*:*:*:*",
|
||||||
|
"cpe:2.3:a:jenkins:cloudbees_installation_manager:2.89.0.33:*:*:*:*:java:*:*",
|
||||||
|
"cpe:2.3:a:jenkins:cloudbees_installation_manager:2.89.0.33:*:*:*:*:maven:*:*",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user