From fd9a9198717f506c36a3686125c3506b58497846 Mon Sep 17 00:00:00 2001 From: Chris Werner Rau Date: Wed, 18 Dec 2024 11:57:19 +0100 Subject: [PATCH] fix(ci/cve-scanning): remove duplicates in reports --- .github/scripts/generate-sarif-reports.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/generate-sarif-reports.sh b/.github/scripts/generate-sarif-reports.sh index 7d7b24e91..8ef67706b 100755 --- a/.github/scripts/generate-sarif-reports.sh +++ b/.github/scripts/generate-sarif-reports.sh @@ -19,7 +19,7 @@ function createSarifReports() { yq -r '.[] | .image' | parallel ${GITHUB_JOB+--bar} --retries 10 -P 0 -k generateSarifReport "$chart" "{}" "reports/$chartName-{#}.json" # shellcheck disable=SC1009 - cat "reports/$chartName-"*.json | jq -r -s '{"$schema": .[0]["$schema"], version: .[0].version, runs: [reduce map(.runs[])[] as $run (null; .+$run as $new | .tool.driver.rules |= (.+$run.tool.driver.rules|unique_by(.id)) | $new*. | .results += ($run.results | map(.locations |= (([.[] | select(.physicalLocation)][0].physicalLocation.artifactLocation) as $physicalLocation | .[] | select(.logicalLocations)[] | map({physicalLocation:{artifactLocation:{uri:"\(.fullyQualifiedName)/\($run.properties.imageName)/\($run.originalUriBaseIds[$physicalLocation.uriBaseId].uri)\($physicalLocation.uri)"}}})))) | del(.properties, .originalUriBaseIds))]}' >"reports/$chartName.json.sarif" + cat "reports/$chartName-"*.json | jq -r -s '. as $input | {"$schema": .[0]["$schema"], version: .[0].version, runs: [reduce map(.runs[])[] as $run (null; .+$run as $new | .tool.driver.rules |= (.+$run.tool.driver.rules|unique_by(.id)) | $new*. | del(.properties, .originalUriBaseIds, .results))]} | .runs[0].results = ($input | reduce map(.runs[])[] as $run ([]; . += ($run.results | map(.locations |= (([.[] | select(.physicalLocation)][0].physicalLocation.artifactLocation) as $physicalLocation | .[] | select(.logicalLocations)[] | map({physicalLocation:{artifactLocation:{uri:"\(.fullyQualifiedName)/\($run.properties.imageName)/\($run.originalUriBaseIds[$physicalLocation.uriBaseId].uri)\($physicalLocation.uri)"}}}))))))' >"reports/$chartName.json.sarif" } function generateSarifReport() {