Skip to content

Commit

Permalink
feat: Add passing checks count to ConfigAuditReport summary (#348)
Browse files Browse the repository at this point in the history
Resolves: #334
  • Loading branch information
mlevesquedion committed Jan 17, 2021
1 parent 725dd4f commit 585c4b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/apis/aquasecurity/v1alpha1/config_audit_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ var (
Type: "date",
Name: "Age",
},
{
JSONPath: ".report.summary.passCount",
Type: "integer",
Name: "Pass",
Priority: 1,
},
{
JSONPath: ".report.summary.dangerCount",
Type: "integer",
Expand All @@ -74,6 +80,7 @@ const (
)

type ConfigAuditSummary struct {
PassCount int `json:"passCount"`
DangerCount int `json:"dangerCount"`
WarningCount int `json:"warningCount"`
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/polaris/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ func (p *plugin) configAuditResultFrom(result Result) (v1alpha1.ConfigAuditResul
}, nil
}

// TODO Add success checks count to the ConfigAuditSummary
func (p *plugin) configAuditSummaryFrom(podChecks []v1alpha1.Check, containerChecks map[string][]v1alpha1.Check) v1alpha1.ConfigAuditSummary {
var summary v1alpha1.ConfigAuditSummary
for _, c := range podChecks {
if c.Success {
summary.PassCount++
continue
}
switch c.Severity {
Expand All @@ -194,6 +194,7 @@ func (p *plugin) configAuditSummaryFrom(podChecks []v1alpha1.Check, containerChe
for _, checks := range containerChecks {
for _, c := range checks {
if c.Success {
summary.PassCount++
continue
}
switch c.Severity {
Expand Down
1 change: 1 addition & 0 deletions pkg/polaris/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func TestPlugin_ParseConfigAuditResult(t *testing.T) {
Version: "3.0",
}, result.Scanner)
assert.Equal(t, v1alpha1.ConfigAuditSummary{
PassCount: 2,
DangerCount: 1,
WarningCount: 1,
}, result.Summary)
Expand Down

0 comments on commit 585c4b6

Please sign in to comment.