From b6e4380937dd3b9d14566b533de6b8f9570240d1 Mon Sep 17 00:00:00 2001 From: halfluke Date: Sat, 21 Oct 2023 01:43:46 +0100 Subject: [PATCH 1/2] fix537 --- functions/helper_lib.sh | 6 +++--- tests/2_docker_daemon_configuration.sh | 17 ++++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/functions/helper_lib.sh b/functions/helper_lib.sh index 005cd9c6..6b3fd80b 100644 --- a/functions/helper_lib.sh +++ b/functions/helper_lib.sh @@ -110,8 +110,8 @@ get_docker_configuration_file() { CONFIG_FILE="$FILE" return fi - if [ -f '/etc/docker/daemon.json' ]; then - CONFIG_FILE='/etc/docker/daemon.json' + if [ -f '/home/kali/SUKA/daemon.json' ]; then + CONFIG_FILE='/home/kali/SUKA/daemon.json' return fi CONFIG_FILE='/dev/null' @@ -125,7 +125,7 @@ get_docker_configuration_file_args() { if "$HAVE_JQ"; then jq --monochrome-output --raw-output ".[\"${OPTION}\"]" "$CONFIG_FILE" else - cat "$CONFIG_FILE" | tr { '\n' | tr , '\n' | tr } '\n' | grep "$OPTION" | sed 's/.*://g' | tr -d '" ', + cat "$CONFIG_FILE" | tr , '\n' | grep "$OPTION" | sed 's/.*://g' | tr -d '" ', fi } diff --git a/tests/2_docker_daemon_configuration.sh b/tests/2_docker_daemon_configuration.sh index cc187d6c..000381fd 100644 --- a/tests/2_docker_daemon_configuration.sh +++ b/tests/2_docker_daemon_configuration.sh @@ -34,7 +34,7 @@ check_2_2() { logcheckresult "PASS" return fi - if get_docker_configuration_file_args 'icc' | grep "false" >/dev/null 2>&1; then + if [[ $(get_docker_configuration_file_args 'icc' | grep "false") ]] && [[ $(get_docker_configuration_file_args 'icc' | grep "false") != "null" ]] ; then pass -s "$check" logcheckresult "PASS" return @@ -93,7 +93,7 @@ check_2_4() { logcheckresult "WARN" return fi - if get_docker_configuration_file_args 'iptables' | grep "false" >/dev/null 2>&1; then + if [[ $(get_docker_configuration_file_args 'iptables' | grep "false") ]] && [[ $(get_docker_configuration_file_args 'iptables' | grep "false") != "null" ]] ; then warn -s "$check" logcheckresult "WARN" return @@ -115,12 +115,7 @@ check_2_5() { logcheckresult "WARN" return fi - if ! [ -z "$(get_docker_configuration_file_args 'insecure-registries')" ]; then - if get_docker_configuration_file_args 'insecure-registries' | grep '\[]' >/dev/null 2>&1; then - pass -s "$check" - logcheckresult "PASS" - return - fi + if [[ $(get_docker_configuration_file_args 'insecure-registries' | grep -v '\[]') ]] && [[ $(get_docker_configuration_file_args 'insecure-registries' | grep -v '\[]') != "null" ]] ; then warn -s "$check" logcheckresult "WARN" return @@ -187,7 +182,7 @@ check_2_8() { local check="$id - $desc" starttestjson "$id" "$desc" - if get_docker_configuration_file_args 'default-ulimit' | grep -v '{}' >/dev/null 2>&1; then + if [[ $(get_docker_configuration_file_args 'default-ulimits' | grep -v '{}') ]] && [[ $(get_docker_configuration_file_args 'default-ulimits' | grep -v '{}') != "null" ]] ; then pass -c "$check" logcheckresult "PASS" return @@ -210,7 +205,7 @@ check_2_9() { local check="$id - $desc" starttestjson "$id" "$desc" - if get_docker_configuration_file_args 'userns-remap' | grep -v '""'; then + if [[ $(get_docker_configuration_file_args 'userns-remap' | grep -v '""') ]] && [[ $(get_docker_configuration_file_args 'userns-remap' | grep -v '""') != "null" ]] ; then pass -s "$check" logcheckresult "PASS" return @@ -278,7 +273,7 @@ check_2_12() { local check="$id - $desc" starttestjson "$id" "$desc" - if get_docker_configuration_file_args 'authorization-plugins' | grep -v '\[]'; then + if [[ $(get_docker_configuration_file_args 'authorization-plugins' | grep -v '\[]') ]] && [[ $(get_docker_configuration_file_args 'authorization-plugins' | grep -v '\[]') != "null" ]] ; then pass -s "$check" logcheckresult "PASS" return From 8d97756c62715c5a0c9bce9e0b69ce57cdbb3e23 Mon Sep 17 00:00:00 2001 From: halfluke Date: Sat, 21 Oct 2023 01:55:29 +0100 Subject: [PATCH 2/2] fix537_proper --- functions/helper_lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/helper_lib.sh b/functions/helper_lib.sh index 6b3fd80b..963b1491 100644 --- a/functions/helper_lib.sh +++ b/functions/helper_lib.sh @@ -110,8 +110,8 @@ get_docker_configuration_file() { CONFIG_FILE="$FILE" return fi - if [ -f '/home/kali/SUKA/daemon.json' ]; then - CONFIG_FILE='/home/kali/SUKA/daemon.json' + if [ -f '/etc/docker/daemon.json' ]; then + CONFIG_FILE='/etc/docker/daemon.json' return fi CONFIG_FILE='/dev/null'