File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,8 +24,27 @@ python3 "$RECATEGORIZE_SCRIPT" \
2424 " $CODING_STANDARDS_CONFIG " \
2525 " $SARIF_FILE " \
2626 " sarif-results-recategorized/$( basename " $SARIF_FILE " ) "
27- rm " $SARIF_FILE "
28- mv " sarif-results-recategorized/$( basename " $SARIF_FILE " ) " " $SARIF_FILE "
27+ PY_EXIT=$?
28+ if [ $PY_EXIT -ne 0 ]; then
29+ echo " Recategorization failed (exit code $PY_EXIT ). SARIF file not updated." >&2
30+ exit $PY_EXIT
31+ fi
32+ rm " $SARIF_FILE "
33+ mv " sarif-results-recategorized/$( basename " $SARIF_FILE " ) " " $SARIF_FILE "
2934
35+ # Ensure jq is available
36+ if ! command -v jq > /dev/null 2>&1 ; then
37+ echo " Error: jq is required but not installed. Please install jq and rerun this script." >&2
38+ exit 1
39+ fi
3040
31- # adding filters later
41+ # Filter SARIF to only include results from repos/* (relative or absolute)
42+ echo " Filtering SARIF results to only include entries with paths matching (^|/)repos/ ..."
43+ jq ' (.runs) |= map(.results |= map(select((.locations // [] | length > 0) and ((.locations[0].physicalLocation.artifactLocation.uri // "") | test("(^|/)repos/")))) )' " $SARIF_FILE " > " ${SARIF_FILE} .filtered"
44+ if [ $? -eq 0 ]; then
45+ mv " ${SARIF_FILE} .filtered" " $SARIF_FILE "
46+ else
47+ echo " jq filtering failed. SARIF file was not modified." >&2
48+ rm -f " ${SARIF_FILE} .filtered"
49+ exit 1
50+ fi
You can’t perform that action at this time.
0 commit comments