Skip to content

Commit 3551f82

Browse files
committed
fix(ZMS): normalize monorepo Psalm SARIF before Code Scanning upload
GitHub rejects SARIF with zero line/column values, which blocked uploads and left test-path alerts open after suppressions merged.
1 parent 3ea57ca commit 3551f82

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

.github/workflows/psalm.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,37 @@ jobs:
215215
echo "Psalm monorepo scan reported issues (exit code: ${psalm_exit}); SARIF will still be uploaded."
216216
fi
217217
218+
- name: Normalize monorepo SARIF for Code Scanning
219+
run: |
220+
python - <<'PY'
221+
import json
222+
223+
sarif_path = "results-monorepo.sarif"
224+
with open(sarif_path, "r", encoding="utf-8") as file:
225+
sarif = json.load(file)
226+
227+
fixed_regions = 0
228+
for run in sarif.get("runs", []):
229+
for result in run.get("results", []):
230+
for location in result.get("locations", []):
231+
region = (
232+
location.get("physicalLocation", {})
233+
.get("region")
234+
)
235+
if not isinstance(region, dict):
236+
continue
237+
for key in ("startLine", "startColumn", "endLine", "endColumn"):
238+
value = region.get(key)
239+
if value is None or value < 1:
240+
region[key] = 1
241+
fixed_regions += 1
242+
243+
with open(sarif_path, "w", encoding="utf-8") as file:
244+
json.dump(sarif, file)
245+
246+
print(f"Normalized {fixed_regions} invalid SARIF region value(s).")
247+
PY
248+
218249
- name: Check monorepo SARIF file exists
219250
id: sarif_monorepo
220251
run: |

0 commit comments

Comments
 (0)