Skip to content

Commit

Permalink
fix: k8s summary separate infra and user finding results
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <hen.keinan@gmail.com>
  • Loading branch information
chen-keinan committed Feb 18, 2024
1 parent c921d57 commit 177abbb
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions pkg/k8s/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,21 @@ func SeparateMisconfigReports(k8sReport Report, scanners types.Scanners, compone

var workloadMisconfig, infraMisconfig, rbacAssessment, workloadVulnerabilities, infraVulnerabilities, workloadResource []Resource
for _, resource := range k8sReport.Resources {
if vulnerabilitiesOrSecretResource(resource) {
switch {
case vulnerabilitiesOrSecretResource(resource):
if resource.Namespace == infraNamespace || nodeInfoResource(resource) {
infraVulnerabilities = append(infraVulnerabilities, nodeKind(resource))
} else {
workloadVulnerabilities = append(workloadVulnerabilities, resource)
}
continue
}

switch {
case scanners.Enabled(types.RBACScanner) && rbacResource(resource):
rbacAssessment = append(rbacAssessment, resource)
case infraResource(resource):
infraMisconfig = append(infraMisconfig, nodeKind(resource))

case scanners.Enabled(types.MisconfigScanner) && !rbacResource(resource):
if slices.Contains(components, workloadComponent) {
workloadMisconfig = append(workloadMisconfig, resource)
}
case scanners.Enabled(types.MisconfigScanner) &&
!rbacResource(resource) &&
slices.Contains(components, workloadComponent):
workloadMisconfig = append(workloadMisconfig, resource)
}
}

Expand All @@ -169,7 +165,6 @@ func SeparateMisconfigReports(k8sReport Report, scanners types.Scanners, compone
Resources: workloadResource,
name: "Workload Assessment",
}

if slices.Contains(components, workloadComponent) {
r = append(r, reports{
Report: workloadReport,
Expand Down

0 comments on commit 177abbb

Please sign in to comment.