1
0
mirror of https://github.com/aquasecurity/kube-bench.git synced 2024-12-24 15:38:06 +00:00

Merge pull request #108 from wmedlar/feature/issue-107

Allow kubernetes version and config directory to be specified (resolves #107). Thank you @wmedlar!
This commit is contained in:
Liz Rice 2018-04-16 17:17:45 +01:00 committed by GitHub
commit ec51a4eabb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -47,7 +47,13 @@ func runChecks(t check.NodeType) {
nodetype = "federated" nodetype = "federated"
} }
ver := getKubeVersion() var ver string
if kubeVersion != "" {
ver = kubeVersion
} else {
ver = getKubeVersion()
}
switch ver { switch ver {
case "1.9", "1.10": case "1.9", "1.10":
continueWithError(nil, fmt.Sprintf("No CIS spec for %s - using tests from CIS 1.2.0 spec for Kubernetes 1.8\n", ver)) continueWithError(nil, fmt.Sprintf("No CIS spec for %s - using tests from CIS 1.2.0 spec for Kubernetes 1.8\n", ver))

View File

@ -26,9 +26,10 @@ import (
var ( var (
envVarsPrefix = "KUBE_BENCH" envVarsPrefix = "KUBE_BENCH"
cfgDir = "./cfg"
defaultKubeVersion = "1.6" defaultKubeVersion = "1.6"
kubeVersion string
cfgFile string cfgFile string
cfgDir string
jsonFmt bool jsonFmt bool
pgSQL bool pgSQL bool
checkList string checkList string
@ -85,6 +86,8 @@ func init() {
`Run all the checks under this comma-delimited list of groups. Example --group="1.1"`, `Run all the checks under this comma-delimited list of groups. Example --group="1.1"`,
) )
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ./cfg/config.yaml)") RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ./cfg/config.yaml)")
RootCmd.PersistentFlags().StringVarP(&cfgDir, "config-dir", "D", "./cfg/", "config directory")
RootCmd.PersistentFlags().StringVar(&kubeVersion, "version", "", "Manually specify Kubernetes version, automatically detected if unset")
goflag.CommandLine.VisitAll(func(goflag *goflag.Flag) { goflag.CommandLine.VisitAll(func(goflag *goflag.Flag) {
RootCmd.PersistentFlags().AddGoFlag(goflag) RootCmd.PersistentFlags().AddGoFlag(goflag)