Skip to content

Commit a663e28

Browse files
TMHSDigitalclaude
andcommitted
ci: list HOL plugin scan findings even when the gate fails
The scanner action publishes its summary and SARIF only on a passing scan, so the first run failed on a high finding without saying which. Read the SARIF report in a follow-up step and write the findings to the log and job summary on every run. Refs #510 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4ce4ff8 commit a663e28

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

‎.github/workflows/plugin-scan.yml‎

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,34 @@ jobs:
5959
cisco_skill_scan: ${{ inputs.cisco && 'on' || 'auto' }}
6060
install_cisco: ${{ inputs.cisco || false }}
6161

62-
- name: Record the score
63-
if: always() && steps.scan.outputs.score != ''
62+
# The action publishes its summary and SARIF only when the scan passes,
63+
# so list the findings from the report here, pass or fail.
64+
- name: List the findings
65+
if: always() && hashFiles('plugin-scan.sarif') != ''
66+
env:
67+
SCORE: ${{ steps.scan.outputs.score }}
68+
GRADE: ${{ steps.scan.outputs.grade }}
6469
run: |
65-
echo "score=${{ steps.scan.outputs.score }} grade=${{ steps.scan.outputs.grade }}" \
66-
"max_severity=${{ steps.scan.outputs.max_severity }}" \
67-
"findings=${{ steps.scan.outputs.findings_total }}"
70+
python3 - << 'PYEOF'
71+
import json, os
72+
sarif = json.load(open("plugin-scan.sarif", encoding="utf-8"))
73+
rules = {r["id"]: r for run in sarif.get("runs", [])
74+
for r in run.get("tool", {}).get("driver", {}).get("rules", [])}
75+
lines = [f"### HOL plugin scan: score {os.environ['SCORE']} ({os.environ['GRADE']})", "",
76+
"| Level | Rule | Where | Finding |", "| --- | --- | --- | --- |"]
77+
for run in sarif.get("runs", []):
78+
for res in run.get("results", []):
79+
loc = res.get("locations") or [{}]
80+
phys = loc[0].get("physicalLocation", {})
81+
where = phys.get("artifactLocation", {}).get("uri", "")
82+
line = phys.get("region", {}).get("startLine")
83+
where += f":{line}" if line else ""
84+
rule = res.get("ruleId", "")
85+
sev = (res.get("properties") or {}).get("severity") or res.get("level", "")
86+
msg = res.get("message", {}).get("text", "").replace("|", "/").replace("\n", " ")
87+
lines.append(f"| {sev} | `{rule}` | `{where}` | {msg} |")
88+
text = "\n".join(lines) + "\n"
89+
print(text)
90+
with open(os.environ["GITHUB_STEP_SUMMARY"], "a", encoding="utf-8") as fh:
91+
fh.write(text)
92+
PYEOF

0 commit comments

Comments
 (0)