From fa8bad20db100d95cf089b0b2d897c339327215c Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Tue, 16 Jul 2019 13:20:30 +0200 Subject: Use -n instead of ! -z --- include/tests_tooling | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'include/tests_tooling') diff --git a/include/tests_tooling b/include/tests_tooling index c752dbde..f07bcdac 100644 --- a/include/tests_tooling +++ b/include/tests_tooling @@ -71,7 +71,7 @@ fi # Cfengine - if [ ! -z "${CFAGENTBINARY}" ]; then + if [ -n "${CFAGENTBINARY}" ]; then LogText "Result: CFEngine (cfagent) is installed (${CFAGENTBINARY})" AUTOMATION_TOOL_FOUND=1 CFENGINE_AGENT_FOUND=1 @@ -129,7 +129,7 @@ fi fi - if [ ! -z "${PUPPETBINARY}" ]; then + if [ -n "${PUPPETBINARY}" ]; then LogText "Result: Puppet is installed (${PUPPETBINARY})" AUTOMATION_TOOL_FOUND=1 Report "automation_tool_running[]=puppet-agent" @@ -145,14 +145,14 @@ fi # SaltStack - if [ ! -z "${SALTMINIONBINARY}" ]; then + if [ -n "${SALTMINIONBINARY}" ]; then LogText "Result: SaltStack (salt-minion) is installed (${SALTMINIONBINARY})" AUTOMATION_TOOL_FOUND=1 SALT_MINION_RUNNING=1 Report "automation_tool_running[]=saltstack-minion" Display --indent 4 --text "- SaltStack minion (salt-minion)" --result "${STATUS_FOUND}" --color GREEN fi - if [ ! -z "${SALTMASTERBINARY}" ]; then + if [ -n "${SALTMASTERBINARY}" ]; then LogText "Result: SaltStack (salt-master) is installed (${SALTMASTERBINARY})" AUTOMATION_TOOL_FOUND=1 SALT_MASTER_RUNNING=1 @@ -188,7 +188,7 @@ if [ ${SKIPTEST} -eq 0 ]; then # Fail2ban presence - if [ ! -z "${FAIL2BANBINARY}" ]; then + if [ -n "${FAIL2BANBINARY}" ]; then FAIL2BAN_FOUND=1 IDS_IPS_TOOL_FOUND=1 LogText "Result: Fail2ban is installed (${FAIL2BANBINARY})" @@ -209,10 +209,10 @@ fi # Continue if tooling is available and configuration file found - if [ ${FAIL2BAN_FOUND} -eq 1 -a ! -z "${FAIL2BAN_CONFIG}" ]; then + if [ ${FAIL2BAN_FOUND} -eq 1 -a -n "${FAIL2BAN_CONFIG}" ]; then Report "fail2ban_config=${FAIL2BAN_CONFIG}" FAIL2BANCLIENT=$(which fail2ban-client 2> /dev/null | grep -v "no [^ ]* in ") - if [ ! -z "${FAIL2BANCLIENT}" ]; then PERFORM_FAIL2BAN_TESTS=1; fi + if [ -n "${FAIL2BANCLIENT}" ]; then PERFORM_FAIL2BAN_TESTS=1; fi fi fi # @@ -224,7 +224,7 @@ Register --test-no TOOL-5104 --weight L --network NO --preqs-met ${PREQS_MET} --category security --description "Enabled tests in Fail2ban" if [ ${SKIPTEST} -eq 0 ]; then FIND=$(${FAIL2BANCLIENT} -d | ${TRBINARY} -d '[]' | ${TRBINARY} -d "'" | ${AWKBINARY} -F, '{ if ($1=="add") { print $2 }}' | ${TRBINARY} -d ' ') - if [ ! -z "${FIND}" ]; then + if [ -n "${FIND}" ]; then for F2BSERVICE in ${FIND}; do LogText "Result: service '${F2BSERVICE}' enabled" Report "fail2ban_enabled_service[]=${F2BSERVICE}" @@ -252,12 +252,12 @@ # FIND=$(${EGREPBINARY} "^action = \%\(action_m.*\)s" ${FAIL2BAN_CONFIG}) # FIND2=$(${EGREPBINARY} "^action = \%\(action_\)s" ${FAIL2BAN_CONFIG}) # - # if [ ! -z "${FIND}" ]; then + # if [ -n "${FIND}" ]; then # FAIL2BAN_EMAIL=1 # LogText "Result: found at least one jail which sends an email alert" # fi # - # if [ ! -z "${FIND2}" ]; then + # if [ -n "${FIND2}" ]; then # FAIL2BAN_SILENT=1 # LogText "Result: found at least one jail which does NOT send an email alert" # fi @@ -298,9 +298,9 @@ # # LogText "Checking for fail2ban iptables chains" # - # if [ ! -z "${IPTABLESBINARY}" ]; then + # if [ -n "${IPTABLESBINARY}" ]; then # CHECK_CHAINS=$(${IPTABLESBINARY} -L 2>&1 | ${GREPBINARY} fail2ban) - # if [ ! -z "${CHECK_CHAINS}" ]; then + # if [ -n "${CHECK_CHAINS}" ]; then # LogText "Result: found at least one iptables chain for fail2ban" # Display --indent 4 --text "- Checking for Fail2ban iptables chain" --result "${STATUS_OK}" --color GREEN # else -- cgit v1.2.3