From addd48c4ddcbb6b784108bfdbe688dcf42993cd4 Mon Sep 17 00:00:00 2001 From: Thibault Ayanides Date: Mon, 7 Dec 2020 13:26:51 +0100 Subject: [PATCH] IMP(shellcheck): add prefix to follow scripts (SC1090) --- bin/hardening.sh | 6 +++++- bin/hardening/8.3.2_tripwire_cron.sh | 2 +- lib/main.sh | 8 ++++++-- tests/launch_tests.sh | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bin/hardening.sh b/bin/hardening.sh index 88e9d26..7ea4c00 100755 --- a/bin/hardening.sh +++ b/bin/hardening.sh @@ -171,6 +171,7 @@ fi # Source Root Dir Parameter if [ -r /etc/default/cis-hardening ]; then + # shellcheck source=../debian/default . /etc/default/cis-hardening fi if [ -z "$CIS_ROOT_DIR" ]; then @@ -178,10 +179,13 @@ if [ -z "$CIS_ROOT_DIR" ]; then echo "Cannot source CIS_ROOT_DIR variable, aborting." exit 128 fi - +# shellcheck source=../lib/constants.sh [ -r $CIS_ROOT_DIR/lib/constants.sh ] && . $CIS_ROOT_DIR/lib/constants.sh +# shellcheck source=../etc/hardening.cfg [ -r $CIS_ROOT_DIR/etc/hardening.cfg ] && . $CIS_ROOT_DIR/etc/hardening.cfg +# shellcheck source=../lib/common.sh [ -r $CIS_ROOT_DIR/lib/common.sh ] && . $CIS_ROOT_DIR/lib/common.sh +# shellcheck source=../lib/utils.sh [ -r $CIS_ROOT_DIR/lib/utils.sh ] && . $CIS_ROOT_DIR/lib/utils.sh if [ $BATCH_MODE ]; then MACHINE_LOG_LEVEL=3; fi diff --git a/bin/hardening/8.3.2_tripwire_cron.sh b/bin/hardening/8.3.2_tripwire_cron.sh index 339cca0..b23fa5b 100755 --- a/bin/hardening/8.3.2_tripwire_cron.sh +++ b/bin/hardening/8.3.2_tripwire_cron.sh @@ -74,7 +74,7 @@ fi # Main function, will call the proper functions given the configuration (audit, enabled, disabled) if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then - # shellcheck source=/opt/debian-cis/lib/main.sh + # shellcheck source=../../lib/main.sh . "$CIS_ROOT_DIR"/lib/main.sh else echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening" diff --git a/lib/main.sh b/lib/main.sh index cf26272..e18d3a3 100644 --- a/lib/main.sh +++ b/lib/main.sh @@ -10,10 +10,13 @@ BATCH_OUTPUT="" status="" forcedstatus="" SUDO_CMD="" - +# shellcheck source=constants.sh [ -r $CIS_ROOT_DIR/lib/constants.sh ] && . $CIS_ROOT_DIR/lib/constants.sh +# shellcheck source=../etc/hardening.cfg [ -r $CIS_ROOT_DIR/etc/hardening.cfg ] && . $CIS_ROOT_DIR/etc/hardening.cfg +# shellcheck source=../lib/common.sh [ -r $CIS_ROOT_DIR/lib/common.sh ] && . $CIS_ROOT_DIR/lib/common.sh +# shellcheck source=../lib/utils.sh [ -r $CIS_ROOT_DIR/lib/utils.sh ] && . $CIS_ROOT_DIR/lib/utils.sh # Environment Sanitizing @@ -46,6 +49,7 @@ while [[ $# > 0 ]]; do debug "Auditing in batch mode, will limit output by setting LOGLEVEL to 'ok'." BATCH_MODE=1 LOGLEVEL=ok + # shellcheck source=../lib/common.sh [ -r $CIS_ROOT_DIR/lib/common.sh ] && . $CIS_ROOT_DIR/lib/common.sh ;; *) @@ -76,7 +80,7 @@ if [ "$forcedstatus" = "createconfig" ]; then debug "$CIS_ROOT_DIR/etc/conf.d/$SCRIPT_NAME.cfg has been created" exit 0 fi - +# shellcheck source=/dev/null [ -r $CIS_ROOT_DIR/etc/conf.d/$SCRIPT_NAME.cfg ] && . $CIS_ROOT_DIR/etc/conf.d/$SCRIPT_NAME.cfg # Now check configured value for status, and potential cmdline parameter diff --git a/tests/launch_tests.sh b/tests/launch_tests.sh index 737ad38..7935436 100755 --- a/tests/launch_tests.sh +++ b/tests/launch_tests.sh @@ -146,7 +146,7 @@ _run() { if [ ! -f "$(dirname "$0")"/lib.sh ]; then fatal "Cannot locate lib.sh" fi -# shellcheck source=/opt/debian-cis/tests/lib.sh +# shellcheck source=../tests/lib.sh . "$(dirname "$0")"/lib.sh ###################