Search endpoint script fail silently 76/88776/4
authorLucjan Bryndza <lbryndza@samsung.com>
Wed, 29 May 2019 14:02:46 +0000 (16:02 +0200)
committerLucjan Bryndza <l.bryndza@samsung.com>
Wed, 29 May 2019 15:32:23 +0000 (17:32 +0200)
When nmap or other commands are not installed on the system
script fail silently without any information

Signed-off-by: Lucjan Bryndza <l.bryndza@samsung.com>
Change-Id: I599b987e223f88617aefa2c0de6cdcbbf3ff50b7
Issue-ID: SECCOM-231

test/security/check_for_http_endpoints.sh

index c0da428..5c2ba20 100755 (executable)
 # Output: List of pods exposing http endpoints
 #
 
+#Prerequisities commands list
+REQ_APPS=(kubectl nmap awk column sort paste grep wc)
+
+# Check for prerequisites apps
+for cmd in "${REQ_APPS[@]}"; do
+       if ! [ -x "$(command -v "$cmd")" ]; then
+               echo "Error: command $cmd is not installed"
+               exit 1
+       fi
+done
+
 if [ "$#" -lt 1 ]; then
     echo "Usage: $0 <k8s-namespace>"
     exit 1