File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 : |
You can’t perform that action at this time.
0 commit comments