Sort controls, update gif

Sort control output
This commit is contained in:
David Wertenteil
2021-08-19 22:45:01 +03:00
committed by GitHub
4 changed files with 36 additions and 8 deletions
+19 -3
View File
@@ -3,7 +3,7 @@
Kubescape is the first tool for testing if Kubernetes is deployed securely as defined in [Kubernetes Hardening Guidance by to NSA and CISA](https://www.nsa.gov/News-Features/Feature-Stories/Article-View/Article/2716980/nsa-cisa-release-kubernetes-hardening-guidance/)
Tests are configured with YAML files, making this tool easy to update as test specifications evolve.
<img src="docs/using-mov.gif">
<img src="docs/demo.gif">
# TL;DR
## Installation
@@ -24,7 +24,7 @@ kubescape scan framework nsa --exclude-namespaces kube-system,kube-public
If you wish to scan all namespaces in your cluster, remove the `--exclude-namespaces` flag.
<img src="docs/run.jpeg">
<img src="docs/summery.PNG">
# Status
@@ -32,7 +32,23 @@ If you wish to scan all namespaces in your cluster, remove the `--exclude-namesp
[![Github All Releases](https://img.shields.io/github/downloads/armosec/kubescape/total.svg)]()
# How to build
`go mod tidy && go build -o kubescape` :zany_face:
1. Clone Project
```
git clone git@github.com:armosec/kubescape.git kubescape && cd "$_"
```
2. Build
```
go mod tidy && go build -o kubescape .
```
3. Run
```
./kubescape scan framework nsa --exclude-namespaces kube-system,kube-public
```
4. Enjoy :zany_face:
# Under the hood
Executable
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 897 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

+17 -5
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"kube-escape/cautils"
"os"
"sort"
"kube-escape/cautils/k8sinterface"
"kube-escape/cautils/opapolicy"
@@ -68,12 +69,14 @@ func (printer *Printer) SummerySetup(postureReport *opapolicy.PostureReport) {
}
func (printer *Printer) PrintResults() {
for control, controlSummery := range printer.summery {
printer.printTitle(control, &controlSummery)
printer.printResult(control, &controlSummery)
controlNames := printer.getSortedControlsNames()
for i := 0; i < len(controlNames); i++ {
controlSummery := printer.summery[controlNames[i]]
printer.printTitle(controlNames[i], &controlSummery)
printer.printResult(controlNames[i], &controlSummery)
if controlSummery.TotalResources > 0 {
printer.printSummery(control, &controlSummery)
if printer.summery[controlNames[i]].TotalResources > 0 {
printer.printSummery(controlNames[i], &controlSummery)
}
}
@@ -165,3 +168,12 @@ func (printer *Printer) PrintSummaryTable() {
summaryTable.SetFooter(generateFooter(len(printer.summery), sumFailed, sumTotal))
summaryTable.Render()
}
func (printer *Printer) getSortedControlsNames() []string {
controlNames := make([]string, 0, len(printer.summery))
for k := range printer.summery {
controlNames = append(controlNames, k)
}
sort.Strings(controlNames)
return controlNames
}