diff --git a/README.md b/README.md index c230f86b..a013322e 100644 --- a/README.md +++ b/README.md @@ -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. - + # 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. - + # 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 diff --git a/docs/demo.gif b/docs/demo.gif new file mode 100755 index 00000000..c5b9ffce Binary files /dev/null and b/docs/demo.gif differ diff --git a/docs/summery.PNG b/docs/summery.PNG new file mode 100755 index 00000000..d3e7d5ce Binary files /dev/null and b/docs/summery.PNG differ diff --git a/printer/printresults.go b/printer/printresults.go index 21bd7de3..5a0435b7 100644 --- a/printer/printresults.go +++ b/printer/printresults.go @@ -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 +}