Skip to content

fix(k8s): skip passed misconfigs for the summary report [backport: release/v0.61] #8748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/k8s/report/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ func accumulateSeverityCounts(finding Resource) (map[string]int, map[string]int,
vCount[rv.Severity]++
}
for _, rv := range r.Misconfigurations {
if rv.Status == types.MisconfStatusPassed {
continue
}
mCount[rv.Severity]++
}
for _, rv := range r.Secrets {
Expand Down
19 changes: 12 additions & 7 deletions pkg/k8s/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ var (
Status: types.MisconfStatusFailure,
Severity: "HIGH",
},
{
ID: "KSV-ID103",
Status: types.MisconfStatusPassed,
Severity: "HIGH",
},

{
ID: "KCV-ID100",
Expand Down Expand Up @@ -265,7 +270,7 @@ func TestReportWrite_Table(t *testing.T) {
expectedOutput string
}{
{
name: "Only config, all serverities",
name: "Only config, all severities",
report: report.Report{
ClusterName: "test",
Resources: []report.Resource{deployOrionWithMisconfigs},
Expand Down Expand Up @@ -319,7 +324,7 @@ See https://google.com/search?q=bad%20config
────────────────────────────────────────`,
},
{
name: "Only vuln, all serverities",
name: "Only vuln, all severities",
report: report.Report{
ClusterName: "test",
Resources: []report.Resource{deployOrionWithVulns},
Expand Down Expand Up @@ -371,7 +376,7 @@ Total: 1 (LOW: 1)
└─────────┴───────────────┴──────────┴─────────┴───────────────────┴───────────────┴───────────────────────────────────────────┘`,
},
{
name: "Only rbac, all serverities",
name: "Only rbac, all severities",
report: report.Report{
ClusterName: "test",
Resources: []report.Resource{roleWithMisconfig},
Expand All @@ -393,7 +398,7 @@ RBAC Assessment
Severities: C=CRITICAL H=HIGH M=MEDIUM L=LOW U=UNKNOWN`,
},
{
name: "Only secret, all serverities",
name: "Only secret, all severities",
report: report.Report{
ClusterName: "test",
Resources: []report.Resource{deployLuaWithSecrets},
Expand Down Expand Up @@ -424,7 +429,7 @@ Infra Assessment
Severities: C=CRITICAL H=HIGH M=MEDIUM L=LOW U=UNKNOWN`,
},
{
name: "apiserver, only infra and serverities",
name: "apiserver, only infra and severities",
report: report.Report{
ClusterName: "test",
Resources: []report.Resource{apiseverPodWithMisconfigAndInfra},
Expand Down Expand Up @@ -455,7 +460,7 @@ Infra Assessment
Severities: C=CRITICAL H=HIGH M=MEDIUM L=LOW U=UNKNOWN`,
},
{
name: "apiserver, vuln,config,secret and serverities",
name: "apiserver, vuln,config,secret and severities",
report: report.Report{
ClusterName: "test",
Resources: []report.Resource{apiseverPodWithMisconfigAndInfra},
Expand Down Expand Up @@ -490,7 +495,7 @@ Infra Assessment
Severities: C=CRITICAL H=HIGH M=MEDIUM L=LOW U=UNKNOWN`,
},
{
name: "apiserver, all misconfig and vuln scanners and serverities",
name: "apiserver, all misconfig and vuln scanners and severities",
report: report.Report{
ClusterName: "test",
Resources: []report.Resource{apiseverPodWithMisconfigAndInfra},
Expand Down
Loading