mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2024-11-22 16:18:07 +00:00
Add few modifications.
This commit is contained in:
parent
3d395994b0
commit
f589fd58e1
@ -106,7 +106,7 @@ func (c *Check) Run(verbose bool) {
|
|||||||
cs[i-1].Stdout, err = cs[i].StdinPipe()
|
cs[i-1].Stdout, err = cs[i].StdinPipe()
|
||||||
errmsgs += handleError(
|
errmsgs += handleError(
|
||||||
err,
|
err,
|
||||||
fmt.Sprintf("check.Run: Audit %s failed\nfailing command: %s",
|
fmt.Sprintf("failed to run: %s\nfailed command: %s",
|
||||||
c.Audit,
|
c.Audit,
|
||||||
cs[i].Args,
|
cs[i].Args,
|
||||||
),
|
),
|
||||||
@ -121,7 +121,7 @@ func (c *Check) Run(verbose bool) {
|
|||||||
err := cs[i].Start()
|
err := cs[i].Start()
|
||||||
errmsgs += handleError(
|
errmsgs += handleError(
|
||||||
err,
|
err,
|
||||||
fmt.Sprintf("check.Run: Audit %s failed\nfailing command: %s",
|
fmt.Sprintf("failed to run: %s\nfailed command: %s",
|
||||||
c.Audit,
|
c.Audit,
|
||||||
cs[i].Args,
|
cs[i].Args,
|
||||||
),
|
),
|
||||||
@ -135,7 +135,7 @@ func (c *Check) Run(verbose bool) {
|
|||||||
err := cs[i].Wait()
|
err := cs[i].Wait()
|
||||||
errmsgs += handleError(
|
errmsgs += handleError(
|
||||||
err,
|
err,
|
||||||
fmt.Sprintf("check.Run: Audit %s failed\nfailing command: %s",
|
fmt.Sprintf("failed to run: %s\nfailed command:%s",
|
||||||
c.Audit,
|
c.Audit,
|
||||||
cs[i].Args,
|
cs[i].Args,
|
||||||
),
|
),
|
||||||
|
16
cmd/util.go
16
cmd/util.go
@ -56,7 +56,13 @@ func verifyBin(binPath ...string) []string {
|
|||||||
// Construct proc name for ps(1)
|
// Construct proc name for ps(1)
|
||||||
for _, b := range binPath {
|
for _, b := range binPath {
|
||||||
binList += b + ","
|
binList += b + ","
|
||||||
|
_, err := exec.LookPath(b)
|
||||||
|
errmsgs += handleError(
|
||||||
|
err,
|
||||||
|
fmt.Sprintf("%s: command not found in path", b),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
binList = strings.Trim(binList, ",")
|
binList = strings.Trim(binList, ",")
|
||||||
|
|
||||||
// Run ps command
|
// Run ps command
|
||||||
@ -64,7 +70,7 @@ func verifyBin(binPath ...string) []string {
|
|||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
errmsgs += handleError(
|
errmsgs += handleError(
|
||||||
err,
|
err,
|
||||||
fmt.Sprintf("verifyBin: %s failed", binList),
|
fmt.Sprintf("failed to run: %s", cmd.Args),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Actual verification
|
// Actual verification
|
||||||
@ -84,12 +90,18 @@ func verifyKubeVersion(b string) []string {
|
|||||||
// TODO! Check the version number using kubectl, which is more likely to be on the path.
|
// TODO! Check the version number using kubectl, which is more likely to be on the path.
|
||||||
var w []string
|
var w []string
|
||||||
|
|
||||||
|
_, err := exec.LookPath(b)
|
||||||
|
errmsgs += handleError(
|
||||||
|
err,
|
||||||
|
fmt.Sprintf("%s: command not found on path - version check skipped", b),
|
||||||
|
)
|
||||||
|
|
||||||
// Check version
|
// Check version
|
||||||
cmd := exec.Command(b, "--version")
|
cmd := exec.Command(b, "--version")
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
errmsgs += handleError(
|
errmsgs += handleError(
|
||||||
err,
|
err,
|
||||||
fmt.Sprintf("verifyKubeVersion: failed\nCommand:%s", cmd.Args),
|
fmt.Sprintf("failed to run:%s", cmd.Args),
|
||||||
)
|
)
|
||||||
|
|
||||||
matched := strings.Contains(string(out), kubeVersion)
|
matched := strings.Contains(string(out), kubeVersion)
|
||||||
|
Loading…
Reference in New Issue
Block a user