diff --git a/.github/scripts/generate-sarif-reports.sh b/.github/scripts/generate-sarif-reports.sh index 79847bbf9..76da51eca 100755 --- a/.github/scripts/generate-sarif-reports.sh +++ b/.github/scripts/generate-sarif-reports.sh @@ -30,6 +30,8 @@ function generateSarifReport() { awk '{print $NF}' | jq -r -c -Rn '[inputs] | map({fullyQualifiedName: .})')" trivy image "$image" -f sarif --quiet --ignore-unfixed | jq -r --argjson locations "$locationsJson" '.runs |= map(.results |= map(.locations |= ([$locations[], .[]])))' >"$outFile" + # delete empty files, otherwise the check if they should be uploaded doesn't work correctly + [[ -s "$outFile" ]] || rm -f "$outFile" } export -f generateSarifReport