|
59 | 59 | cisco_skill_scan: ${{ inputs.cisco && 'on' || 'auto' }} |
60 | 60 | install_cisco: ${{ inputs.cisco || false }} |
61 | 61 |
|
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 }} |
64 | 69 | 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