This repository has been archived by the owner on Oct 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Display CIS Benchmark results (#18)
Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>
- Loading branch information
1 parent
864215a
commit 7237616
Showing
24 changed files
with
594 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package view | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
sec "github.com/aquasecurity/k8s-security-crds/pkg/apis/aquasecurity/v1alpha1" | ||
"github.com/vmware-tanzu/octant/pkg/view/component" | ||
) | ||
|
||
func NewCISKubernetesBenchmarksReport(benchmark sec.CISKubernetesBenchmark) (flexLayout component.FlexLayout) { | ||
flexLayout = *component.NewFlexLayout("CIS Kubernetes Benchmark") | ||
uiSections := make([]component.FlexLayoutItem, len(benchmark.Report.Sections)) | ||
|
||
for i, section := range benchmark.Report.Sections { | ||
uiSections[i] = component.FlexLayoutItem{ | ||
Width: component.WidthFull, | ||
View: createTableForSection(section), | ||
} | ||
} | ||
|
||
uiSections = append([]component.FlexLayoutItem{ | ||
{ | ||
Width: component.WidthThird, | ||
View: NewReportSummary(benchmark.Report.GeneratedAt.Time), | ||
}, | ||
{ | ||
Width: component.WidthThird, | ||
View: NewScannerSummary(benchmark.Report.Scanner), | ||
}, | ||
{ | ||
Width: component.WidthThird, | ||
View: NewCISKubernetesBenchmarksSummary(benchmark), | ||
}, | ||
}, uiSections...) | ||
|
||
flexLayout.AddSections(uiSections) | ||
return | ||
} | ||
|
||
func createTableForSection(section sec.CISKubernetesBenchmarkSection) component.Component { | ||
table := component.NewTableWithRows( | ||
fmt.Sprintf("%s %s", section.ID, section.Text), "There are no results!", | ||
component.NewTableCols("Status", "Number", "Description", "Scored"), | ||
[]component.TableRow{}) | ||
|
||
for _, test := range section.Tests { | ||
for _, result := range test.Results { | ||
|
||
tr := component.TableRow{ | ||
"Status": component.NewText(result.Status), | ||
"Number": component.NewText(result.TestNumber), | ||
"Description": component.NewText(result.TestDesc), | ||
"Scored": component.NewText(strconv.FormatBool(result.Scored)), | ||
} | ||
table.Add(tr) | ||
} | ||
} | ||
|
||
return table | ||
} | ||
|
||
// TODO Implement summary counting | ||
func NewCISKubernetesBenchmarksSummary(_ sec.CISKubernetesBenchmark) (c *component.Summary) { | ||
c = component.NewSummary("Summary") | ||
|
||
sections := []component.SummarySection{ | ||
{Header: "PASS ", Content: component.NewText(strconv.Itoa(30))}, | ||
{Header: "WARN ", Content: component.NewText(strconv.Itoa(10))}, | ||
{Header: "FAIL ", Content: component.NewText(strconv.Itoa(12))}, | ||
} | ||
c.Add(sections...) | ||
return | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.