From 36615818a2542ae37fcd8e05d2d2b605555c44c3 Mon Sep 17 00:00:00 2001 From: Saumya Rai Date: Tue, 24 Mar 2026 13:05:05 +0530 Subject: [PATCH 1/3] Add placeholder comment for filters in script Added a placeholder comment for future filter implementation. Signed-off-by: Saumya Rai --- scripts/workflow/recategorize_guidelines.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/workflow/recategorize_guidelines.sh b/scripts/workflow/recategorize_guidelines.sh index 8fa4b736020..95f3c792e6f 100755 --- a/scripts/workflow/recategorize_guidelines.sh +++ b/scripts/workflow/recategorize_guidelines.sh @@ -26,3 +26,6 @@ python3 "$RECATEGORIZE_SCRIPT" \ "sarif-results-recategorized/$(basename "$SARIF_FILE")" rm "$SARIF_FILE" mv "sarif-results-recategorized/$(basename "$SARIF_FILE")" "$SARIF_FILE" + + +#adding filters later From 41860d94add65239f229ea4889ad486c527e3d13 Mon Sep 17 00:00:00 2001 From: Saumya Rai Date: Tue, 24 Mar 2026 17:07:45 +0530 Subject: [PATCH 2/3] Enhance recategorization script with error handling Added error handling for recategorization and ensured jq is installed before filtering SARIF results. Signed-off-by: Saumya Rai --- scripts/workflow/recategorize_guidelines.sh | 25 ++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/scripts/workflow/recategorize_guidelines.sh b/scripts/workflow/recategorize_guidelines.sh index 95f3c792e6f..c5beb5a16cc 100755 --- a/scripts/workflow/recategorize_guidelines.sh +++ b/scripts/workflow/recategorize_guidelines.sh @@ -24,8 +24,27 @@ python3 "$RECATEGORIZE_SCRIPT" \ "$CODING_STANDARDS_CONFIG" \ "$SARIF_FILE" \ "sarif-results-recategorized/$(basename "$SARIF_FILE")" - rm "$SARIF_FILE" - mv "sarif-results-recategorized/$(basename "$SARIF_FILE")" "$SARIF_FILE" +PY_EXIT=$? +if [ $PY_EXIT -ne 0 ]; then + echo "Recategorization failed (exit code $PY_EXIT). SARIF file not updated." >&2 + exit $PY_EXIT +fi +rm "$SARIF_FILE" +mv "sarif-results-recategorized/$(basename "$SARIF_FILE")" "$SARIF_FILE" +# Ensure jq is available +if ! command -v jq >/dev/null 2>&1; then + echo "Error: jq is required but not installed. Please install jq and rerun this script." >&2 + exit 1 +fi -#adding filters later +# Filter SARIF to only include results from repos/* (relative or absolute) +echo "Filtering SARIF results to only include entries with paths matching (^|/)repos/ ..." +jq '(.runs) |= map(.results |= map(select((.locations // [] | length > 0) and ((.locations[0].physicalLocation.artifactLocation.uri // "") | test("(^|/)repos/")))) )' "$SARIF_FILE" > "${SARIF_FILE}.filtered" +if [ $? -eq 0 ]; then + mv "${SARIF_FILE}.filtered" "$SARIF_FILE" +else + echo "jq filtering failed. SARIF file was not modified." >&2 + rm -f "${SARIF_FILE}.filtered" + exit 1 +fi From c2323e66731ba06ef722dddb3929d0a8bb160c30 Mon Sep 17 00:00:00 2001 From: Saumya Rai Date: Wed, 25 Mar 2026 12:57:27 +0530 Subject: [PATCH 3/3] Comment out error handling and jq filtering Commented out error handling and jq filtering sections in the script. Signed-off-by: Saumya Rai --- scripts/workflow/recategorize_guidelines.sh | 40 ++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/workflow/recategorize_guidelines.sh b/scripts/workflow/recategorize_guidelines.sh index c5beb5a16cc..6ec2088f409 100755 --- a/scripts/workflow/recategorize_guidelines.sh +++ b/scripts/workflow/recategorize_guidelines.sh @@ -24,27 +24,27 @@ python3 "$RECATEGORIZE_SCRIPT" \ "$CODING_STANDARDS_CONFIG" \ "$SARIF_FILE" \ "sarif-results-recategorized/$(basename "$SARIF_FILE")" -PY_EXIT=$? -if [ $PY_EXIT -ne 0 ]; then - echo "Recategorization failed (exit code $PY_EXIT). SARIF file not updated." >&2 - exit $PY_EXIT -fi +# PY_EXIT=$? +# if [ $PY_EXIT -ne 0 ]; then +# echo "Recategorization failed (exit code $PY_EXIT). SARIF file not updated." >&2 +# exit $PY_EXIT +# fi rm "$SARIF_FILE" mv "sarif-results-recategorized/$(basename "$SARIF_FILE")" "$SARIF_FILE" -# Ensure jq is available -if ! command -v jq >/dev/null 2>&1; then - echo "Error: jq is required but not installed. Please install jq and rerun this script." >&2 - exit 1 -fi +# # Ensure jq is available +# if ! command -v jq >/dev/null 2>&1; then +# echo "Error: jq is required but not installed. Please install jq and rerun this script." >&2 +# exit 1 +# fi -# Filter SARIF to only include results from repos/* (relative or absolute) -echo "Filtering SARIF results to only include entries with paths matching (^|/)repos/ ..." -jq '(.runs) |= map(.results |= map(select((.locations // [] | length > 0) and ((.locations[0].physicalLocation.artifactLocation.uri // "") | test("(^|/)repos/")))) )' "$SARIF_FILE" > "${SARIF_FILE}.filtered" -if [ $? -eq 0 ]; then - mv "${SARIF_FILE}.filtered" "$SARIF_FILE" -else - echo "jq filtering failed. SARIF file was not modified." >&2 - rm -f "${SARIF_FILE}.filtered" - exit 1 -fi +# # Filter SARIF to only include results from repos/* (relative or absolute) +# echo "Filtering SARIF results to only include entries with paths matching (^|/)repos/ ..." +# jq '(.runs) |= map(.results |= map(select((.locations // [] | length > 0) and ((.locations[0].physicalLocation.artifactLocation.uri // "") | test("(^|/)repos/")))) )' "$SARIF_FILE" > "${SARIF_FILE}.filtered" +# if [ $? -eq 0 ]; then +# mv "${SARIF_FILE}.filtered" "$SARIF_FILE" +# else +# echo "jq filtering failed. SARIF file was not modified." >&2 +# rm -f "${SARIF_FILE}.filtered" +# exit 1 +# fi