Skip to content

Commit

Permalink
Sort controls, update gif
Browse files Browse the repository at this point in the history
Sort control output
  • Loading branch information
dwertent committed Aug 19, 2021
2 parents 35ea718 + b92a44d commit b2d14a7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,15 +24,31 @@ 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
[![build](https://github.com/armosec/kubescape/actions/workflows/build.yaml/badge.svg)](https://github.com/armosec/kubescape/actions/workflows/build.yaml)
[![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

Expand Down
Binary file added docs/demo.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/summery.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 18 additions & 6 deletions printer/printresults.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"kube-escape/cautils"
"os"
"sort"

"kube-escape/cautils/k8sinterface"
"kube-escape/cautils/opapolicy"
Expand Down Expand Up @@ -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)

if controlSummery.TotalResources > 0 {
printer.printSummery(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 printer.summery[controlNames[i]].TotalResources > 0 {
printer.printSummery(controlNames[i], &controlSummery)
}

}
Expand Down Expand Up @@ -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
}

0 comments on commit b2d14a7

Please sign in to comment.