Skip to content

Commit

Permalink
fix: set correct version of ShellCheck in SARIF
Browse files Browse the repository at this point in the history
  • Loading branch information
jamacku committed Aug 15, 2023
1 parent f043ea6 commit 75f9ccd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,23 @@ uploadSARIF () {
fi
}

get_shellcheck_version () {
local shellcheck_version
shellcheck_version=$(shellcheck --version | grep -w "version:" | cut -s -d ' ' -f 2)

Check notice

Code scanning / shellcheck

Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore). Note

Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).

echo "${shellcheck_version}"
}

# Function that shows versions of currently used commands
show_versions() {
local shellcheck
local csutils

shellcheck=$(shellcheck --version | grep "version:")
shellcheck=$(get_shellcheck_version)
csutils=$(csdiff --version)

echo -e "\
ShellCheck: ${shellcheck//'version: '/}
ShellCheck: ${shellcheck}
csutils: ${csutils}"
}

Expand Down
5 changes: 3 additions & 2 deletions src/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ else
cp ../defects.log ../sarif-defects.log
fi

shellcheck_version=$(get_shellcheck_version)

# GitHub requires an absolute path, so let's remove the './' prefix from it.
# TODO: Don't hardcode ShellCheck version
csgrep \
--strip-path-prefix './' \
--mode=sarif \
--set-scan-prop='tool:ShellCheck' \
--set-scan-prop='tool-version:0.8.0' \
--set-scan-prop="tool-version:${shellcheck_version}" \
--set-scan-prop='tool-url:https://www.shellcheck.net/wiki/' \
'../sarif-defects.log' >> output.sarif

Expand Down

0 comments on commit 75f9ccd

Please sign in to comment.