Support CIS ACK 1.0.0 benchmark (#841)

* Support CIS ACK 1.0.0 benchmark

* fix yaml lint

* Fix TestMakeSubsitutions may failed when order of map changed

* Support auto-detect platform when running on ACK

* Apply suggestions from code review

Co-authored-by: Yoav Rotem <yoavrotems97@gmail.com>

Co-authored-by: Yoav Rotem <yoavrotems97@gmail.com>
This commit is contained in:
Huang Huang
2021-05-11 11:52:24 +03:00
committed by GitHub
co-authored by Yoav Rotem
parent 887965d31f
commit 47c2494728
12 changed files with 1998 additions and 14 deletions
+19 -4
View File
@@ -15,14 +15,16 @@
package cmd
import (
"github.com/magiconair/properties/assert"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"sort"
"strconv"
"testing"
"github.com/magiconair/properties/assert"
"github.com/aquasecurity/kube-bench/check"
"github.com/spf13/viper"
)
@@ -389,9 +391,9 @@ func TestGetServiceFiles(t *testing.T) {
func TestMakeSubsitutions(t *testing.T) {
cases := []struct {
input string
subst map[string]string
exp string
input string
subst map[string]string
exp string
expectedSubs []string
}{
{input: "Replace $thisbin", subst: map[string]string{"this": "that"}, exp: "Replace that", expectedSubs: []string{"that"}},
@@ -404,6 +406,7 @@ func TestMakeSubsitutions(t *testing.T) {
if s != c.exp {
t.Fatalf("Got %s expected %s", s, c.exp)
}
sort.Strings(subs)
assert.Equal(t, c.expectedSubs, subs)
})
}
@@ -536,6 +539,11 @@ func Test_getPlatformNameFromKubectlOutput(t *testing.T) {
args: args{s: "v1.17.6-gke.1"},
want: "gke",
},
{
name: "ack",
args: args{s: "v1.18.8-aliyun.1"},
want: "aliyun",
},
{
name: "unknown",
args: args{s: "v1.17.6"},
@@ -579,6 +587,13 @@ func Test_getPlatformBenchmarkVersion(t *testing.T) {
},
want: "gke-1.0",
},
{
name: "aliyun",
args: args{
platform: "aliyun",
},
want: "ack-1.0",
},
{
name: "unknown",
args: args{