Repository navigation
feat(ci): add optional SARIF upload for reusable Tier 1 scans - #900
pt-bhavsar wants to merge 9 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Prashant Bhavsar <pt.bhavsar@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Prashant Bhavsar <pt.bhavsar@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
Valid skill-relative findings can be rejected as ambiguous when root and skill files share a name, aborting SARIF publication because retained reports lose their explicit path base.
1 open issue
What changed in this PR
Adds opt-in GitHub Code Scanning publication to the reusable Tier 1 workflow, addressing #898 while preserving default permissions and existing artifacts.
Changes:
- Combines complete full-scan SARIF reports into one analysis with a caller-configurable category, including failed policy verdicts.
- Skips changed-only scans and rejects incomplete reports or unsupported publication contexts.
- Adds focused tests and documents permissions, category selection, and fork PR limitations.
| File | Description |
|---|---|
| tests/ci/test_evaluate_workflow.py | Tests publication controls, report merging, location handling, and failure cases. |
| docs/github-actions.mdx | Documents opt-in publication, permissions, and baseline safeguards. |
| CHANGELOG.md | Announces optional SARIF publication. |
| .github/workflows/evaluate-skills.yml | Adds publication inputs, scan exit tracking, SARIF preparation, and upload. |
Review effort: Balanced
chrisknvidia
left a comment
There was a problem hiding this comment.
Thanks for this, it is a careful piece of work and the tests cover the awkward cases (changed-only scans, aborted scans, fork PRs, pull_request_target, malformed or partial evidence). I read the workflow and the embedded merge script, ran tests/ci/test_evaluate_workflow.py (47 pass at your head; the 20 new tests fail against main's workflow, as they should) plus the CI workflow, onboarding, run_tier1, redaction and reporter suites (559 pass), and pushed a real Tier 1 run through the CI redaction path and then your merge script: the result is one run with $schema, version 2.1.0, the driver name, deduplicated rules, repository-relative artifact URIs and no automationDetails, so the category input applies. The upload-sarif pin resolves to the v4.39.3 tag and matches the one already used in docs/ci-integration.mdx.
Behaviour is unchanged for callers that do not set upload-sarif: the only unconditional change is capturing the docker run exit code, and the existing shell tests still pass. Permissions stay inherited from the caller, which is the right shape for a reusable workflow, and the docs ask for security-events: write at the caller's job level only.
One thing before merge: main moved under you and CHANGELOG.md now conflicts (both sides added a bullet at the top of Unreleased / Added), so a rebase is needed.
One more thing I hit while poking at the merge script, which the inline comment above already points at: the relative-URI branch raises "a SARIF location is ambiguous" whenever the same relative path exists at both the repository root and inside the skill, and that is common in practice. In CI the per-skill SARIF is re-rendered by ci/secret_redaction.py with a bare SARIFReporter(), so PII, unicode-smuggling and hygiene findings arrive with skill-relative URIs such as README.md or scripts/run.sh, and most skill repositories also carry a README.md at the root. I reproduced it with the script extracted from this workflow: a summary.json for skills/foo, a child SARIF whose location is README.md, and a README.md in both places; the step exits 1 with that message, no catalog is written, and the job fails even though the scan completed. Since every relative URI the image emits is relative to the scanned skill (absolute ones already arrive as file:///workspace/...), I would resolve relative URIs against the row's path unconditionally, drop the existence-based disambiguation, and add a regression case with the same file name at the root and in the skill. Separately, not blocking: the exit-code plumbing between the scan step and the SARIF step (id: scan, the set +e / exit-code output, SCAN_EXIT_CODE) has no test; I removed each of them in turn and all 47 tests stayed green, while publication would then always stop at "did not finish normally".
The rest inline are non-blocking suggestions.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Prashant Bhavsar <pt.bhavsar@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Prashant Bhavsar <pt.bhavsar@gmail.com>
chrisknvidia
left a comment
There was a problem hiding this comment.
I went over the follow-up push separately. I extracted the merge script before and after and diffed it: the workspace mount and existence check are gone, relative URIs always resolve under the skill path, the fork-PR branch warns and exits 0, and a result-count warning was added. I ran the script against a real redacted Tier 1 report produced from a fake workspace and the URIs come out as skills/<name>/... as expected; traversal, absolute, scheme, netloc, query, fragment and percent-encoded .. URIs are all rejected and nothing is written. Duplicate rule ids resolve to the last skill's metadata deterministically. The count check does not drop anything, so over 25,000 results the upload step will fail the job; the docs are honest about that. Reverting each production hunk on its own makes at least one of the new tests fail; the only wiring the tests do not cover is the ready=true echo. The pin, the absence of a permissions block and the pull_request_target refusal are unchanged. Remaining comments are nits.
Signed-off-by: Prashant Bhavsar <pt.bhavsar@gmail.com>
0ab167f to
71ab33e
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Prashant Bhavsar <pt.bhavsar@gmail.com>
chrisknvidia
left a comment
There was a problem hiding this comment.
I checked the hardening commit on its own: with each new check reverted one at a time, the type checks on location, physicalLocation and artifactLocation, the warning initialisation, the warnings.md write and the step-summary append each make at least one new test fail, and I could not get a traceback out of the merge script with any malformed location, result, run, summary row or URI I tried; everything exits with the 'upload skipped' message. Two small things: the {"not": "a-list"} row does not actually cover the new 'locations must be a list' check (an empty dict or string does), and the new double-prefix test pins the opposite of what finding_repository_path does for the same input in the annotations, which is worth a sentence in the test or an alignment.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Prashant Bhavsar <pt.bhavsar@gmail.com>
| for location in locations: | ||
| normalize_location(location, row["path"]) | ||
| documents.append(document) | ||
| merged = merge_catalog_sarif_documents(documents) |
There was a problem hiding this comment.
[P3] Keep shared SARIF rule descriptions independent of individual skills
The catalog merge keeps one rule descriptor per rule ID. Each child report currently fills fullDescription.text with that skill's finding message, so the last skill supplies the shared description. In a two-skill scan with different name mismatches, both individual messages and paths were correct, but the shared rule description named the second skill even for the first result. GitHub displays that description alongside associated results. Use a generic rule description or omit the shared fullDescription when merging, while keeping each result's message. GitHub SARIF field reference
There was a problem hiding this comment.
Looks like the issue stems from original sarif generation of each skills. I pushed some updates to fix that. Currently I am mutating the rules rid of fullDescription. That should help, but post new image generation, that can be reverted or kept. Either way it should be fine. Let me know what you think.
One rule descriptor is kept per rule ID, but each child report filled fullDescription with a single finding's message, so the last finding (or the last skill in a merged catalog) described every result for that rule in GitHub Code Scanning. Drop the per-finding text from the descriptor and strip it from child reports in the reusable workflow so callers on already-published image digests get the same result. Signed-off-by: Prashant Bhavsar <pt.bhavsar@gmail.com>
GitHub Code Scanning displays a result only when it has a location. Findings without a file, such as dependency CVE findings from the plugin audit, were emitted with no locations, accepted by the upload, and then never shown. Anchor them at the scanned skill directory in the reporter when the scan root is known, and in the reusable workflow for reports from the CI reporter and from earlier images, where the fallback passes through the same workspace-escape checks as every other URI. Signed-off-by: Prashant Bhavsar <pt.bhavsar@gmail.com>

Summary
Add opt-in GitHub Code Scanning publication to the reusable Tier 1 workflow. When enabled, the workflow combines per-skill SARIF reports into one analysis under a caller-configurable category. Existing artifact output and default permissions remain unchanged.
Publication runs after complete scans, including failed policy verdicts. Changed-only scans skip publication, and incomplete or invalid reports fail publication rather than replacing a complete baseline with partial results. The documentation covers permissions, category selection, and fork PR limitations.
Closes #898
Verification
make lintmake testmake buildResults:
make lint— passed.make build— passed.make test— failed on macOS with locked Python 3.12 dependencies: 45,603 passed, 236 skipped, 19 deselected, and 5 failed. Three existing Tier 3 sandbox tests could not access the Copilot Git installation's configuration; two secure-copy race tests encountered permission errors. These failures have not been verified on baseline or Linux.python -m pytest -q tests/ci/test_evaluate_workflow.py tests/ci/test_secret_redaction.py tests/ci/test_run_tier1.py— 267 passed on Python 3.12.actionlint .github/workflows/evaluate-skills.yml— passed../fern/node_modules/.bin/fern check— passed with one warning.python -m pytest -q tests/ci/test_evaluate_workflow.py tests/ci/test_secret_redaction.py tests/ci/test_run_tier1.py tests/reporting/test_reporters.py -k 'sarif or evaluate_workflow or redaction or run_tier1'— 285 passed, 191 deselected.make lint,actionlint .github/workflows/evaluate-skills.yml, and./fern/node_modules/.bin/fern checkpassed again (Fern reported one warning). The full suite and build results above predate the merge.Release Impact
CHANGELOG.md