diff options
author | David Cole <40234707+DavidArthurCole@users.noreply.github.com> | 2024-09-26 03:56:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-26 09:56:44 +0200 |
commit | 092a29dd8b13c2b04b0b7c259446ab697201dd5e (patch) | |
tree | f3704e259d34bfccef083834cb9106578695a694 /.github/scripts/process_detekt_sarif.sh | |
parent | e90fd65559ef551b29de7d28f4fea3a46cc2a4e6 (diff) | |
download | skyhanni-092a29dd8b13c2b04b0b7c259446ab697201dd5e.tar.gz skyhanni-092a29dd8b13c2b04b0b7c259446ab697201dd5e.tar.bz2 skyhanni-092a29dd8b13c2b04b0b7c259446ab697201dd5e.zip |
Backend: Dekekt (#2547)
Co-authored-by: Linnea Gräf <nea@nea.moe>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to '.github/scripts/process_detekt_sarif.sh')
-rw-r--r-- | .github/scripts/process_detekt_sarif.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/.github/scripts/process_detekt_sarif.sh b/.github/scripts/process_detekt_sarif.sh new file mode 100644 index 000000000..7fb4f7e4e --- /dev/null +++ b/.github/scripts/process_detekt_sarif.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# This script processes the Detekt SARIF file and outputs results in a format +# suitable for annotation in CI/CD systems. + +SARIF_FILE="$1" + +# Check if SARIF file exists +if [ ! -f "$SARIF_FILE" ]; then + echo "SARIF file not found: $SARIF_FILE" + exit 1 +fi + +# Define jq command to parse SARIF file +read -r -d '' jq_command <<'EOF' +.runs[].results[] | +{ + "full_path": .locations[].physicalLocation.artifactLocation.uri | sub("file://$(pwd)/"; ""), + "file_name": (.locations[].physicalLocation.artifactLocation.uri | split("/") | last), + "l": .locations[].physicalLocation, + "level": .level, + "message": .message.text, + "ruleId": .ruleId +} | +( + "::" + (.level) + + " file=" + (.full_path) + + ",line=" + (.l.region.startLine|tostring) + + ",title=" + (.ruleId) + + ",col=" + (.l.region.startColumn|tostring) + + ",endColumn=" + (.l.region.endColumn|tostring) + + "::" + (.message.text) +) +EOF + +# Run jq command to format the output +jq -r "$jq_command" < "$SARIF_FILE" |