From ddad135d1337c1e0e5250e488da20bf0159dc0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sj=C3=B6gren?= Date: Wed, 16 Oct 2019 09:49:18 +0200 Subject: [PATCH] shellcheck MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Sjögren --- docker-bench-security.sh | 2 +- output_lib.sh | 2 +- tests/1_host_configuration.sh | 2 +- tests/3_docker_daemon_configuration_files.sh | 12 ++++++------ tests/5_container_runtime.sh | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docker-bench-security.sh b/docker-bench-security.sh index 334492b..c925d75 100755 --- a/docker-bench-security.sh +++ b/docker-bench-security.sh @@ -101,7 +101,7 @@ main () { benchcont="$c" fi done - + # get the image id of the docker_bench_security_image, memorize it: benchimagecont="nil" for c in $(docker images | sed '1d' | awk '{print $3}'); do diff --git a/output_lib.sh b/output_lib.sh index c0de4e4..6f796f5 100644 --- a/output_lib.sh +++ b/output_lib.sh @@ -1,6 +1,6 @@ #!/bin/sh -if ! [ -z "$nocolor" ] && [ "$nocolor" = "nocolor" ]; then +if [ -n "$nocolor" ] && [ "$nocolor" = "nocolor" ]; then bldred='' bldgrn='' bldblu='' diff --git a/tests/1_host_configuration.sh b/tests/1_host_configuration.sh index a9374a1..045b968 100644 --- a/tests/1_host_configuration.sh +++ b/tests/1_host_configuration.sh @@ -110,7 +110,7 @@ check_1_2_3() { starttestjson "$id_1_2_3" "$desc_1_2_3" totalChecks=$((totalChecks + 1)) - file="/usr/bin/dockerd" + file="/usr/bin/dockerd" if command -v auditctl >/dev/null 2>&1; then if auditctl -l | grep "$file" >/dev/null 2>&1; then pass "$check_1_2_3" diff --git a/tests/3_docker_daemon_configuration_files.sh b/tests/3_docker_daemon_configuration_files.sh index ddd3b32..ed9d418 100644 --- a/tests/3_docker_daemon_configuration_files.sh +++ b/tests/3_docker_daemon_configuration_files.sh @@ -255,7 +255,7 @@ check_3_9() { starttestjson "$id_3_9" "$desc_3_9" totalChecks=$((totalChecks + 1)) - if ! [ -z $(get_docker_configuration_file_args 'tlscacert') ]; then + if [ -n "$(get_docker_configuration_file_args 'tlscacert')" ]; then tlscacert=$(get_docker_configuration_file_args 'tlscacert') else tlscacert=$(get_docker_effective_command_line_args '--tlscacert' | sed -n 's/.*tlscacert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1) @@ -287,7 +287,7 @@ check_3_10() { starttestjson "$id_3_10" "$desc_3_10" totalChecks=$((totalChecks + 1)) - if ! [ -z $(get_docker_configuration_file_args 'tlscacert') ]; then + if [ -n "$(get_docker_configuration_file_args 'tlscacert')" ]; then tlscacert=$(get_docker_configuration_file_args 'tlscacert') else tlscacert=$(get_docker_effective_command_line_args '--tlscacert' | sed -n 's/.*tlscacert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1) @@ -319,7 +319,7 @@ check_3_11() { starttestjson "$id_3_11" "$desc_3_11" totalChecks=$((totalChecks + 1)) - if ! [ -z $(get_docker_configuration_file_args 'tlscert') ]; then + if [ -n "$(get_docker_configuration_file_args 'tlscert')" ]; then tlscert=$(get_docker_configuration_file_args 'tlscert') else tlscert=$(get_docker_effective_command_line_args '--tlscert' | sed -n 's/.*tlscert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1) @@ -351,7 +351,7 @@ check_3_12() { starttestjson "$id_3_12" "$desc_3_12" totalChecks=$((totalChecks + 1)) - if ! [ -z $(get_docker_configuration_file_args 'tlscert') ]; then + if [ -n "$(get_docker_configuration_file_args 'tlscert')" ]; then tlscert=$(get_docker_configuration_file_args 'tlscert') else tlscert=$(get_docker_effective_command_line_args '--tlscert' | sed -n 's/.*tlscert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1) @@ -383,7 +383,7 @@ check_3_13() { starttestjson "$id_3_13" "$desc_3_13" totalChecks=$((totalChecks + 1)) - if ! [ -z $(get_docker_configuration_file_args 'tlskey') ]; then + if [ -n "$(get_docker_configuration_file_args 'tlskey')" ]; then tlskey=$(get_docker_configuration_file_args 'tlskey') else tlskey=$(get_docker_effective_command_line_args '--tlskey' | sed -n 's/.*tlskey=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1) @@ -415,7 +415,7 @@ check_3_14() { starttestjson "$id_3_14" "$desc_3_14" totalChecks=$((totalChecks + 1)) - if ! [ -z $(get_docker_configuration_file_args 'tlskey') ]; then + if [ -n "$(get_docker_configuration_file_args 'tlskey')" ]; then tlskey=$(get_docker_configuration_file_args 'tlskey') else tlskey=$(get_docker_effective_command_line_args '--tlskey' | sed -n 's/.*tlskey=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1) diff --git a/tests/5_container_runtime.sh b/tests/5_container_runtime.sh index 343563c..0e3f534 100644 --- a/tests/5_container_runtime.sh +++ b/tests/5_container_runtime.sh @@ -332,7 +332,7 @@ check_5_7() { # iterate through port range (line delimited) for port in $ports; do - if [ ! -z "$port" ] && [ "$port" -lt 1024 ]; then + if [ -n "$port" ] && [ "$port" -lt 1024 ]; then # If it's the first container, fail the test if [ $fail -eq 0 ]; then warn "$check_5_7" @@ -1171,7 +1171,7 @@ check_5_29() { pattern=$(echo "$exclude" | sed 's/,/|/g') cName=$(docker inspect --format '{{.Name}}' "$c" 2>/dev/null | sed 's/\///g' | grep -Ev "$pattern" ) fi - if ! [ -z "$cName" ]; then + if [ -n "$cName" ]; then info " * Container in docker0 network: $cName" docker_network_containers="$docker_network_containers $c:$cName" fi