Draft
Conversation
a8cce1d to
8aaaea5
Compare
PR workflows (test, coverage, integration-tests) previously ran with pull-requests:write, checks:write, and access to CODECOV_TOKEN, meaning untrusted PR code could leverage those permissions. This commit strips all write permissions and secrets from PR-triggered workflows, uploading results as artifacts instead. A new reporting.yaml workflow, triggered by workflow_run, runs in the base repo context with the necessary permissions to publish GitHub Checks, post PR comments, and upload to Codecov. Also removes secrets:inherit from release.yaml → deploy-docs call since GITHUB_TOKEN is auto-available to workflow_call workflows.
8aaaea5 to
b5149dc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
(test.yaml, coverage.yaml, integration-tests.yaml), so untrusted PR code runs with read-only permissions
by workflow_run, which runs in the base repo context with the necessary permissions
workflows)
Motivation
PR workflows currently run untrusted code with tokens that can modify PRs and create checks. The workflow_run event
runs in the context of the base branch, not the PR, so secrets and write permissions are safe to use there.
Changes
File: cargo-check/action.yml
Change: Make github_token optional (only used by cargo audit, which is disabled)
────────────────────────────────────────
File: test.yaml
Change: Drop write perms, disable in-action check publishing, upload test result XMLs and event files as artifacts
────────────────────────────────────────
File: coverage.yaml
Change: Drop job-level write perms, remove PR comment and Codecov upload steps, upload LCOV/summary/event as artifacts
────────────────────────────────────────
File: integration-tests.yaml
Change: Drop write perms, remove 3 PR comment steps, upload event file as artifact
────────────────────────────────────────
File: release.yaml
Change: Remove secrets: inherit from deploy-docs job
────────────────────────────────────────
File: reporting.yaml (new)
Change: workflow_run-triggered workflow with 3 jobs: test-results (publishes per-platform GitHub Checks),
coverage-report (posts PR comment + Codecov upload), integration-report (posts report download links)
Permissions after this change
Workflow: test.yaml
Before: contents: read, pull-requests: write, checks: write
After: contents: read
────────────────────────────────────────
Workflow: coverage.yaml
Before: contents: read + job-level pull-requests: write
After: contents: read
────────────────────────────────────────
Workflow: integration-tests.yaml
Before: contents: read, pull-requests: write
After: contents: read
────────────────────────────────────────
Workflow: reporting.yaml (new)
Before: —
After: contents: read, actions: read, checks: write, pull-requests: write
Test plan
succeeds