Repository navigation
feat: add a runnable SARIF-scan GitHub Actions example - #143
Conversation
docs/ci-integration.md documents the SARIF upload snippet but there was
nothing in the repo you could actually point at or copy-paste and run -
no examples/ workflow, no proof the SARIF this CLI emits is valid
enough for upload-sarif to accept.
Went with examples/github-actions/sarif-scan.yml rather than wiring it
into this repo's own .github/workflows/ - it needs security-events:
write and I'd rather not touch this repo's live CI/permissions from a
first PR here. The example is fully runnable as committed (scans
hack/dev/rbac-fixtures.yaml, no manifests or secrets to fill in first),
someone can copy it in and just swap the --manifests path.
Verified locally:
cd control-plane
python -m app.cli scan rbac \
--manifests ../hack/dev/rbac-fixtures.yaml --output sarif > /tmp/results.sarif
python -c "import json; json.load(open('/tmp/results.sarif'))"
Valid SARIF, 24 results, exit 0, no env vars needed for shift-left mode.
Linked the doc's existing snippet to the new file so they can't drift
silently (the example has checkout/setup-python/install wrapped around
the same two steps, so it's not a byte-for-byte match - noted that in
the doc instead of claiming false equivalence).
Signed-off-by: shariqueahmad108-ship-it <[email protected]>
rrskris
left a comment
There was a problem hiding this comment.
Approving. Sorry this sat four days with no reply — that's on me, not on the PR.
Your verification reproduces exactly. I ran your command against a clean checkout:
exit 0 | valid SARIF 2.1.0 | 24 results | 12 rules | driver: Kaaval
24 results, byte-for-byte the number you claimed. That matters more than it sounds — the whole point of #104 was that docs/ci-integration.md documented a snippet nobody had ever run end to end, and now there's a file that demonstrably produces output upload-sarif accepts.
Things you got right that are easy to get wrong:
defaults.run.working-directory: control-planeapplies torun:steps but not touses:steps, sosarif_file:correctly stays workspace-relative ascontrol-plane/results.sarif. That's the single most common way this workflow shape breaks, and you avoided it.--manifests ../hack/dev/rbac-fixtures.yamlresolves correctly from thecontrol-planeworking directory.- Scanning the fixtures testbed by default means the file genuinely runs as-is. "Copy this and it works before you configure anything" is the right call for an example.
examples/over.github/workflows/was also right, and asking rather than assuming onsecurity-events: writefor a first PR was the correct instinct.
One real issue, which I'll fix myself rather than send you round again. The action versions are stale on arrival, and I checked each against upstream rather than eyeballing them:
| In the example | Current | This repo pins |
|---|---|---|
actions/checkout@v4 |
v7.0.1 | 9c091bb… (v7.0.0) |
actions/setup-python@v5 |
v7.0.0 | 5fda3b9… (v7.0.0) |
codeql-action/upload-sarif@v3 |
v4 | e4fba86… (v4.37.3) |
Three majors behind on two of them. Not your oversight so much as a repo gap: our dependabot.yml registers the github-actions ecosystem at /, but that ecosystem only scans .github/workflows/ — so nothing under examples/ will ever get bumped automatically. This file was going to rot the day it landed regardless of which versions it started on.
I'm not going to ask you to SHA-pin it either. Pinning a file no bot maintains just converts "visibly stale" into "invisibly stale". Better shape for an example is current floating majors plus an explicit note telling readers to pin SHAs in their repo — which is the advice a security tool should be giving anyway.
Follow-up PR from me right behind this one. Merging.
Nice catch on the doc link, too — linking to the file rather than claiming a byte-for-byte match with the inline snippet was the honest framing.
The SARIF example workflow added in #143 shipped three action versions that were already stale: actions/checkout@v4 (current v7), setup-python@v5 (current v7) and codeql-action/upload-sarif@v3 (this repo pins v4.37.3). Root cause is a dependabot blind spot rather than the PR: the github-actions ecosystem only scans .github/workflows/, so nothing under examples/ is bumped automatically and this file would have drifted whatever it started on. Keep floating major tags here — SHA-pinning a file no bot maintains turns visible staleness into invisible staleness — and add an explicit note telling readers to pin SHAs in their own repo, which is the right advice for a workflow granted security-events: write. Document the ecosystem gap in dependabot.yml so the next example does not repeat it. Follow-up to #143 (@shariqueahmad108-ship-it). Signed-off-by: Vamshi Krishna Santhapuri <[email protected]>
What this changes
docs/ci-integration.md documents the SARIF upload snippet, but there's nothing in the repo you could actually copy-paste and run — no examples/ workflow, no proof the SARIF this CLI emits is valid enough for upload-sarif to accept.
Added
examples/github-actions/sarif-scan.yml— a full runnable workflow (checkout, Python setup, install, scan, upload) rather than the bare two-step snippet already in the doc. It scanshack/dev/rbac-fixtures.yamlout of the box, so it runs with nothing filled in first; swap--manifestsfor a real path to use it for real.I went with
examples/rather than wiring this into the repo's own.github/workflows/, since that needssecurity-events: writeand I'd rather not touch this repo's live CI/permissions on a first PR. Happy to move it into.github/workflows/instead if you'd prefer that — say the word.Linked the doc's existing snippet to the new file rather than claiming a byte-for-byte match, since the example has extra scaffolding (checkout/setup-python/install) around the same two core steps.
Closes #104
Type
Checklist
How you verified it
Exit 0, valid SARIF JSON, 24 results, no env vars needed for shift-left mode — confirms the exact command the workflow runs actually produces output
upload-sarifcan accept. Since the workflow lives inexamples/rather than.github/workflows/, it doesn't run in this repo's own CI, so there's no Security-tab screenshot per the issue's conditional ("if it runs in this repo's CI").