aboutsummaryrefslogtreecommitdiffstats
path: root/test/security
diff options
context:
space:
mode:
Diffstat (limited to 'test/security')
-rw-r--r--test/security/k8s/src/check/rancher/rancher.go9
-rw-r--r--test/security/k8s/src/check/raw/raw.go9
2 files changed, 18 insertions, 0 deletions
diff --git a/test/security/k8s/src/check/rancher/rancher.go b/test/security/k8s/src/check/rancher/rancher.go
index 842fd3ff6..b5e382221 100644
--- a/test/security/k8s/src/check/rancher/rancher.go
+++ b/test/security/k8s/src/check/rancher/rancher.go
@@ -58,6 +58,7 @@ func getProcessParams(process check.Command, service check.Service) ([]string, e
return []string{}, err
}
+ cmd = trimOutput(cmd) // TODO: improve `docker ps` query format.
if len(cmd) > 0 {
i := bytes.Index(cmd, []byte(process.String()))
if i == -1 {
@@ -99,6 +100,14 @@ func getPsCmdOutput(host string, service check.Service) ([]byte, error) {
return out, nil
}
+// trimOutput removes trailing new line and brackets from output.
+func trimOutput(b []byte) []byte {
+ b = bytes.TrimSpace(b)
+ b = bytes.TrimPrefix(b, []byte("["))
+ b = bytes.TrimSuffix(b, []byte("]"))
+ return b
+}
+
// btos converts slice of bytes to slice of strings split by white space characters.
func btos(in []byte) []string {
var out []string
diff --git a/test/security/k8s/src/check/raw/raw.go b/test/security/k8s/src/check/raw/raw.go
index 04a6fa554..555115950 100644
--- a/test/security/k8s/src/check/raw/raw.go
+++ b/test/security/k8s/src/check/raw/raw.go
@@ -59,6 +59,7 @@ func getProcessParams(process check.Command) ([]string, error) {
return []string{}, err
}
+ cmd = trimOutput(cmd) // TODO: improve `docker inspect` query format.
if len(cmd) > 0 {
i := bytes.Index(cmd, []byte(process.String()))
if i == -1 {
@@ -158,6 +159,14 @@ func runCommand(cmd string, conn *ssh.Client) ([]byte, error) {
return out, nil
}
+// trimOutput removes trailing new line and brackets from output.
+func trimOutput(b []byte) []byte {
+ b = bytes.TrimSpace(b)
+ b = bytes.TrimPrefix(b, []byte("["))
+ b = bytes.TrimSuffix(b, []byte("]"))
+ return b
+}
+
// btos converts slice of bytes to slice of strings split by white space characters.
func btos(in []byte) []string {
var out []string