From 7616d271e15a4673527a54a0aab424b50dbc5f37 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 16 Apr 2020 13:20:05 -0500 Subject: [PATCH 1/2] Add detection of bash and ruby --- Dockerfile | 2 +- lib/linter.sh | 54 +++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5657f196..00d8c660 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ LABEL com.github.actions.name="GitHub Super-Linter" \ # Run APK installs # #################### RUN apk add --no-cache \ - bash git git-lfs musl-dev curl gcc jq \ + bash git git-lfs musl-dev curl gcc jq file\ npm nodejs \ libxml2-utils perl \ ruby ruby-dev ruby-bundler ruby-rdoc make \ diff --git a/lib/linter.sh b/lib/linter.sh index 17c066ed..37c24f3f 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1221,14 +1221,52 @@ BuildFileList() ########################################################## READ_ONLY_CHANGE_FLAG=1 else - ############################ - # Extension was not found! # - ############################ - echo " - WARN! Failed to get filetype for:[$FILE]!" - ########################################################## - # Set the READ_ONLY_CHANGE_FLAG since this could be exec # - ########################################################## - READ_ONLY_CHANGE_FLAG=1 + ############################################## + # Use file to see if we can parse what it is # + ############################################## + GET_FILE_TYPE_CMD=$(file "$FILE" 2>&1) + + ################# + # Check if bash # + ################# + if [[ "$GET_FILE_TYPE_CMD" =~ *"Bourne-Again shell script"* ]]; then + ####################### + # It is a bash script # + ####################### + echo "WARN! Found bash script without extension:[.sh]" + echo "Please update file with proper extensions." + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_BASH+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + elif [[ "$GET_FILE_TYPE_CMD" =~ *"Ruby script"* ]]; then + ####################### + # It is a Ruby script # + ####################### + echo "WARN! Found ruby script without extension:[.rb]" + echo "Please update file with proper extensions." + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_RUBY+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + else + ############################ + # Extension was not found! # + ############################ + echo " - WARN! Failed to get filetype for:[$FILE]!" + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + fi fi done From e339a967c00f280d76376abd6ca7488b463d93ad Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 16 Apr 2020 13:23:36 -0500 Subject: [PATCH 2/2] fixed it --- lib/linter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 37c24f3f..1c8f2946 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1229,7 +1229,7 @@ BuildFileList() ################# # Check if bash # ################# - if [[ "$GET_FILE_TYPE_CMD" =~ *"Bourne-Again shell script"* ]]; then + if [[ "$GET_FILE_TYPE_CMD" == *"Bourne-Again shell script"* ]]; then ####################### # It is a bash script # ####################### @@ -1243,7 +1243,7 @@ BuildFileList() # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 - elif [[ "$GET_FILE_TYPE_CMD" =~ *"Ruby script"* ]]; then + elif [[ "$GET_FILE_TYPE_CMD" == *"Ruby script"* ]]; then ####################### # It is a Ruby script # #######################