diff --git a/entrypoint.sh b/entrypoint.sh index 8ca5d3e..bfb0746 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -46,7 +46,7 @@ scan_file(){ echo "###############################################" echo " Scanning $file" echo "###############################################" - shellcheck "$file_path" --severity="$severity_mode" + shellcheck -x "$file_path" --severity="$severity_mode" local exit_code=$? if [ $exit_code -eq 0 ] ; then printf "%b" "Successfully scanned ${file_path} 🙌\n" diff --git a/test_data/test_dir/external_sources.sh b/test_data/test_dir/external_sources.sh new file mode 100644 index 0000000..e0d48bd --- /dev/null +++ b/test_data/test_dir/external_sources.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +if [[ -f ./src/tagging.sh ]]; then + . /src/tagging.sh +fi \ No newline at end of file diff --git a/tests/unit_tests/scan_tests.sh b/tests/unit_tests/scan_tests.sh index 1ef1252..379c8be 100755 --- a/tests/unit_tests/scan_tests.sh +++ b/tests/unit_tests/scan_tests.sh @@ -24,6 +24,16 @@ test_scan_unsuppoted_script(){ assertNotContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected2" } +test_scan_external_sourced_file(){ + local actual=$(scan_file ./test_data/test_dir/external_sources.sh) + local notExpected="SC1091: Not following" + local expected="Scanning external_sources.sh" + + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected" + assertNotContains "Actual messages:$actual\n contains the unexpected message: '$notExpected'\n" "$actual" "$notExpected" + +} + # scan_all() tests test_scan_a_directory(){ local message1="Scanning all the shell scripts at ./test_data/script_type"