From 0993c0a13b33f778a664de9ce3e55d7d9580576a Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Sun, 31 Jul 2016 15:58:20 +0200 Subject: [PATCH] Style and readability improvements --- include/profiles | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/include/profiles b/include/profiles index ddecf4d7..4eb0243d 100644 --- a/include/profiles +++ b/include/profiles @@ -25,15 +25,15 @@ for PROFILE in ${PROFILES}; do LogText "Reading profile/configuration ${PROFILE}" - FIND=`egrep "^config:|^[a-z-].*=" ${PROFILE} | sed 's/ /!space!/g'` - for I in ${FIND}; do - if ContainsString "config:" "${I}"; then + FIND=$(egrep "^config:|^[a-z-].*=" ${PROFILE} | sed 's/ /!space!/g') + for CONFIGOPTION in ${FIND}; do + if ContainsString "config:" "${CONFIGOPTION}"; then # Old style configuration - OPTION=`echo ${I} | cut -d ':' -f2` - VALUE=`echo ${I} | cut -d ':' -f3 | sed 's/!space!/ /g'` + OPTION=$(echo ${CONFIGOPTION} | cut -d ':' -f2) + VALUE=$(echo ${CONFIGOPTION} | cut -d ':' -f3 | sed 's/!space!/ /g') else - OPTION=`echo ${I} | cut -d '=' -f1` - VALUE=`echo ${I} | cut -d '=' -f2 | sed 's/!space!/ /g'` + OPTION=$(echo ${CONFIGOPTION} | cut -d '=' -f1) + VALUE=$(echo ${CONFIGOPTION} | cut -d '=' -f2 | sed 's/!space!/ /g') fi Debug "Profile option set: ${OPTION} (with value ${VALUE})" @@ -41,9 +41,9 @@ # Define which compliance standards are enabled compliance_standards | check-compliance) - COMPLIANCE_STANDARDS_ENABLED=`echo ${VALUE} | tr ',' ' '` - for I in ${COMPLIANCE_STANDARDS_ENABLED}; do - case $I in + COMPLIANCE_STANDARDS_ENABLED=$(echo ${VALUE} | tr ',' ' ') + for STANDARD in ${COMPLIANCE_STANDARDS_ENABLED}; do + case ${STANDARD} in cis) COMPLIANCE_ENABLE_CIS=1 ; Debug "Compliance scanning for CIS Benchmarks is enabled" ;; hipaa) COMPLIANCE_ENABLE_HIPAA=1 ; Debug "Compliance scanning for HIPAA is enabled" ;; iso27001) COMPLIANCE_ENABLE_ISO27001=1 ; Debug "Compliance scanning for ISO27001 is enabled" ;; @@ -106,21 +106,21 @@ AddSetting "debian-skip-security-repository" "OPTION_DEBIAN_SKIP_SECURITY_REPOSITORY" "Skip checking for a security repository (Debian and others)" ;; debug) - FIND=`echo "${VALUE}" | egrep "^(1|true|yes)"` && DEBUG=1 + FIND=$(echo "${VALUE}" | egrep "^(1|true|yes)") && DEBUG=1 Debug "Debug mode set to ${DEBUG}" AddSetting "debug" "${DEBUG}" "Debugging mode" ;; # Development mode (--developer) developer-mode) - FIND=`echo "${VALUE}" | egrep "^(1|true|yes)"` && DEVELOPER_MODE=1 + FIND=$(echo "${VALUE}" | egrep "^(1|true|yes)") && DEVELOPER_MODE=1 Debug "Developer mode set to ${DEVELOPER_MODE}" AddSetting "developer" "${DEVELOPER_MODE}" "Developer mode" ;; # Show non-zero exit code when errors are found error-on-warnings) - FIND=`echo "${VALUE}" | egrep "^(1|true|yes)"` && ERROR_ON_WARNINGS=1 + FIND=$(echo "${VALUE}" | egrep "^(1|true|yes)") && ERROR_ON_WARNINGS=1 Debug "Exit with different code on warnings is set to ${ERROR_ON_WARNINGS}" AddSetting "error-on-warnings" "${ERROR_ON_WARNINGS}" "Use non-zero exit code if one or more warnings were found" ;; @@ -201,7 +201,7 @@ quick) # Quick mode (SKIP_PLUGINS) might already be set outside profile, so store in different variable SETTING_QUICK_MODE=0 # default is no - FIND=`echo "${VALUE}" | egrep "^(1|true|yes)$"` && QUICKMODE=1 + FIND=$(echo "${VALUE}" | egrep "^(1|true|yes)$") && QUICKMODE=1 if [ ! -z "${FIND}" ]; then SETTING_QUICK_MODE=1; fi Debug "Quickmode set to ${SETTING_QUICK_MODE}" AddSetting "quick" "${SETTING_QUICK_MODE}" "Quick mode (non-interactive)" @@ -210,7 +210,7 @@ # Inline tips about tool (default enabled) show_tool_tips | show-tool-tips) SETTING_SHOW_TOOL_TIPS=1 # default is yes - FIND=`echo "${VALUE}" | egrep "^(0|false|no)$"` && SHOW_TOOL_TIPS=0 + FIND=$(echo "${VALUE}" | egrep "^(0|false|no)$") && SHOW_TOOL_TIPS=0 if [ ! -z "${FIND}" ]; then SETTING_QUICK_MODE=0; fi Debug "Show tool tips set to ${SETTING_SHOW_TOOL_TIPS}" AddSetting "show-tool-tips" "${SETTING_SHOW_TOOL_TIPS}" "Show tool tips" @@ -220,7 +220,7 @@ show-warnings-only) QUIET=1 QUICKMODE=1 - FIND=`echo "${VALUE}" | egrep "^(1|true|yes)$"` && SHOW_WARNINGS_ONLY=1 + FIND=$(echo "${VALUE}" | egrep "^(1|true|yes)$") && SHOW_WARNINGS_ONLY=1 Debug "Show warnings only set to ${SHOW_WARNINGS_ONLY}" AddSetting "show-warnings-only" "${SHOW_WARNINGS_ONLY}" "Show only warnings" ;; @@ -229,7 +229,7 @@ skip-plugins) # Skip plugins (SKIP_PLUGINS) might already be set, so store in different variable SETTING_SKIP_PLUGINS=0 # default is no - FIND=`echo "${VALUE}" | egrep "^(1|true|yes)$"` && SKIP_PLUGINS=1 + FIND=$(echo "${VALUE}" | egrep "^(1|true|yes)$") && SKIP_PLUGINS=1 if [ ! -z "${FIND}" ]; then SETTING_SKIP_PLUGINS=1; fi Debug "Skip plugins is set to ${SETTING_SKIP_PLUGINS}" AddSetting "skip-plugins" "${SETTING_SKIP_PLUGINS}" "Skip plugins" @@ -244,20 +244,20 @@ # Which tests to skip (skip-test=ABCD-1234 or skip-test=ABCD-1234:subtest) skip-test) - STRING=`echo ${VALUE} | tr '[:lower:]' '[:upper:]'` + STRING=$(echo ${VALUE} | tr '[:lower:]' '[:upper:]') SKIP_TESTS="${SKIP_TESTS} ${STRING}" ;; # Do not check the latest version on the internet skip_upgrade_test | skip-upgrade-test) - FIND=`echo "${VALUE}" | egrep "^(1|true|yes)"` && SKIP_UPGRADE_TEST=1 + FIND=$(echo "${VALUE}" | egrep "^(1|true|yes)") && SKIP_UPGRADE_TEST=1 Debug "Skip upgrade test set to ${SKIP_UPGRADE_TEST}" AddSetting "skip-upgrade-test" "${SKIP_UPGRADE_TEST}" "Skip upgrade test" ;; # Set strict mode for development and quality purposes strict) - FIND=`echo "${VALUE}" | egrep "^(1|true|yes)"` && SET_STRICT=1 + FIND=$(echo "${VALUE}" | egrep "^(1|true|yes)") && SET_STRICT=1 AddSetting "strict" "${SET_STRICT}" "Perform strict test of scripts" ;; @@ -351,7 +351,7 @@ # Verbose output (--verbose) verbose) - FIND=`echo "${VALUE}" | egrep "^(1|true|yes)"` && VERBOSE=1 + FIND=$(echo "${VALUE}" | egrep "^(1|true|yes)") && VERBOSE=1 Debug "Verbose set to ${VERBOSE}" AddSetting "verbose" "${VERBOSE}" "Verbose output" ;; @@ -362,7 +362,7 @@ # Deprecated: skip tests test_skip_always) - STRING=`echo ${VALUE} | tr '[:lower:]' '[:upper:]'` + STRING=$(echo ${VALUE} | tr '[:lower:]' '[:upper:]') SKIP_TESTS="${SKIP_TESTS} ${STRING}" LogText "[deprecated option] Tests to be skipped: ${VALUE}" DisplayToolTip "Replace deprecated option 'test_skip_always' and replace with 'skip-test' (add to custom.prf)"