mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2025-07-07 15:18:17 +00:00
Warn if config files / executables aren't found
This commit is contained in:
parent
1eb8212301
commit
15f5293468
@ -140,11 +140,13 @@ func verifyNodeType(t check.NodeType) {
|
|||||||
confPath = kubeFederatedConf
|
confPath = kubeFederatedConf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// These executables might not be on the user's path.
|
||||||
|
// TODO! Check the version number using kubectl, which is more likely to be on the path.
|
||||||
for _, b := range binPath {
|
for _, b := range binPath {
|
||||||
_, err := exec.LookPath(b)
|
_, err := exec.LookPath(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%s: command not found\n", b)
|
fmt.Fprintf(os.Stderr, "WARNING: %s: command not found on path - version check skipped\n", b)
|
||||||
os.Exit(1)
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check version
|
// Check version
|
||||||
@ -159,9 +161,11 @@ func verifyNodeType(t check.NodeType) {
|
|||||||
)
|
)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if running
|
for _, b := range binPath {
|
||||||
cmd = exec.Command("ps", "-ef")
|
// Check if running.
|
||||||
|
cmd := exec.Command("ps", "-ef")
|
||||||
out, _ = cmd.Output()
|
out, _ = cmd.Output()
|
||||||
if matched, _ := regexp.MatchString(".*"+b, string(out)); !matched {
|
if matched, _ := regexp.MatchString(".*"+b, string(out)); !matched {
|
||||||
fmt.Fprintf(os.Stderr, "%s is not running\n", b)
|
fmt.Fprintf(os.Stderr, "%s is not running\n", b)
|
||||||
@ -171,8 +175,8 @@ func verifyNodeType(t check.NodeType) {
|
|||||||
|
|
||||||
for _, c := range confPath {
|
for _, c := range confPath {
|
||||||
if _, err := os.Stat(c); os.IsNotExist(err) {
|
if _, err := os.Stat(c); os.IsNotExist(err) {
|
||||||
fmt.Fprintf(os.Stderr, "config file %s does not exist\n", c)
|
fmt.Fprintf(os.Stderr, "WARNING: config file %s does not exist\n", c)
|
||||||
os.Exit(1)
|
// os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user