features: config options, saving to file, SARIF

- Upgrade to Hadolint 2.8.0, enabling the SARIF formatter
- Expand config options to reflect more of those regularly available
  with Hadolint including `no-fail` and `failure-threshold` options
- Enable the creation of report files

Breaking change: The list of ignored rules is now comma separated and
not space separated.

fixes: #23
fixes: #36
fixes: #42
This commit is contained in:
Moritz Röhrich
2021-11-20 12:02:12 +01:00
parent 3cfc69d4b2
commit 98fb3f8040
5 changed files with 112 additions and 32 deletions
+11 -5
View File
@@ -23,9 +23,13 @@ if [ -n "$HADOLINT_CONFIG" ]; then
HADOLINT_CONFIG="-c ${HADOLINT_CONFIG}"
fi
for i in $HADOLINT_IGNORE; do
HADOLINT_IGNORE_CMDLINE="${HADOLINT_IGNORE_CMDLINE} --ignore=${i}"
done
OUTPUT=
if [ -n "$HADOLINT_OUTPUT" ]; then
if [ -f "$HADOLINT_OUTPUT" ]; then
HADOLINT_OUTPUT="$TMP_FOLDER/$HADOLINT_OUTPUT"
fi
OUTPUT=" | tee $HADOLINT_OUTPUT"
fi
if [ "$HADOLINT_RECURSIVE" = "true" ]; then
shopt -s globstar
@@ -33,8 +37,10 @@ if [ "$HADOLINT_RECURSIVE" = "true" ]; then
filename="${!#}"
flags="${@:1:$#-1}"
hadolint $HADOLINT_IGNORE_CMDLINE $HADOLINT_CONFIG $flags **/$filename
hadolint $HADOLINT_CONFIG $flags **/$filename $OUTPUT
else
# shellcheck disable=SC2086
hadolint $HADOLINT_IGNORE_CMDLINE $HADOLINT_CONFIG "$@"
hadolint $HADOLINT_CONFIG "$@" $OUTPUT
fi
[ -z "$HADOLINT_OUTPUT" ] || echo "Hadolint output saved to: $HADOLINT_OUTPUT"