mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2025-06-01 05:38:48 +00:00
Update controls to support multiple Kubernetes versions.
This commit is contained in:
parent
f2e744bdcb
commit
8ea0892437
@ -24,6 +24,7 @@ import (
|
|||||||
// Controls holds all controls to check for master nodes.
|
// Controls holds all controls to check for master nodes.
|
||||||
type Controls struct {
|
type Controls struct {
|
||||||
ID string `yaml:"id"`
|
ID string `yaml:"id"`
|
||||||
|
Version string
|
||||||
Text string
|
Text string
|
||||||
Type NodeType
|
Type NodeType
|
||||||
Groups []*Group
|
Groups []*Group
|
||||||
|
@ -11,22 +11,31 @@ const cfgDir = "../cfg/"
|
|||||||
|
|
||||||
// validate that the files we're shipping are valid YAML
|
// validate that the files we're shipping are valid YAML
|
||||||
func TestYamlFiles(t *testing.T) {
|
func TestYamlFiles(t *testing.T) {
|
||||||
files, err := ioutil.ReadDir(cfgDir)
|
// TODO: make this list dynamic
|
||||||
if err != nil {
|
dirs := []string{"1.6/", "1.7/"}
|
||||||
t.Fatalf("error reading %s directory: %v", cfgDir, err)
|
|
||||||
}
|
for _, dir := range dirs {
|
||||||
for _, file := range files {
|
dir = cfgDir + dir
|
||||||
fileName := file.Name()
|
|
||||||
in, err := ioutil.ReadFile(cfgDir + fileName)
|
files, err := ioutil.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error opening file %s: %v", fileName, err)
|
t.Fatalf("error reading %s directory: %v", dir, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c := new(Controls)
|
for _, file := range files {
|
||||||
|
|
||||||
err = yaml.Unmarshal(in, c)
|
fileName := file.Name()
|
||||||
if err != nil {
|
in, err := ioutil.ReadFile(dir + fileName)
|
||||||
t.Fatalf("failed to load YAML from %s: %v", fileName, err)
|
if err != nil {
|
||||||
|
t.Fatalf("error opening file %s: %v", fileName, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c := new(Controls)
|
||||||
|
|
||||||
|
err = yaml.Unmarshal(in, c)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to load YAML from %s: %v", fileName, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user