aboutsummaryrefslogtreecommitdiffstats
path: root/security/scripts/check_cis_kubernetes.sh
diff options
context:
space:
mode:
authormrichomme <morgan.richomme@orange.com>2020-04-20 14:50:27 +0200
committermrichomme <morgan.richomme@orange.com>2020-04-20 14:50:27 +0200
commit5de622a8247c4cf4fc2bd4e5f8a947e60a8c4bfb (patch)
tree2038bfaa94413367fd46e8bcd38600f2e49dac05 /security/scripts/check_cis_kubernetes.sh
parent3c64be99c3c24930674e9fa657993d95cbd2fe6d (diff)
Resync integration/xtesting repo
Issue-ID: INT-1366 Signed-off-by: mrichomme <morgan.richomme@orange.com> Change-Id: I3af9c4697f0e67d3ce5b6d2fceeb978aeb20a0ff
Diffstat (limited to 'security/scripts/check_cis_kubernetes.sh')
-rw-r--r--security/scripts/check_cis_kubernetes.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/security/scripts/check_cis_kubernetes.sh b/security/scripts/check_cis_kubernetes.sh
new file mode 100644
index 0000000..33ffdf5
--- /dev/null
+++ b/security/scripts/check_cis_kubernetes.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+echo "------------------------------------------------------------------------"
+echo "-------------------- ONAP Security tests ----------------------------"
+echo "----------------- Test if K8S is CIS compliant ----------------------"
+echo "------------------------------------------------------------------------"
+
+code=0
+
+CIS_VERSION=${CIS_VERSION:-1.4}
+echo "Running CIS test case version ${CIS_VERSION}"
+kube-bench master --benchmark cis-${CIS_VERSION} > cis_full_test.txt
+cat cis_full_test.txt | grep "\[FAIL]" > cisK8s.txt
+
+if [ -s cisK8s.txt ]
+then
+ code=1
+ nb_errors=`cat cisK8s.txt | wc -l`
+ echo "Test FAIL: $nb_errors assertions not passed"
+ cat cis_full_test.txt
+else
+ echo "Test PASS: Kubernetes Deployment is CIS compatible"
+fi
+
+exit $code