Skip to content

Scope GITHUB_TOKEN permissions in PyPI and finalize release workflows - #41676

Merged
derrickaw merged 1 commit into
masterfrom
codescan/gha-release-workflow-permissions
Nov 25, 2026
Merged

derrickaw merged 1 commit into
masterfrom
codescan/gha-release-workflow-permissions

Conversation

@derrickaw

@derrickaw derrickaw commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Note: this PR was auto-generated by tooling. Before moving it out of draft, the author has done a full review of the PR, specifically evaluating it on the following criteria:

  • The PR remediates confirmed, live Code Scanning finding(s) (CodeQL / zizmor) on master without altering intended public API or workflow semantics
  • The fix is minimal, idiomatic, and avoids masking underlying defects (false positives and noisy rules are dismissed or scoped via config rather than code churn)
  • Relevant unit tests, linters, Gemini review feedback, and live workflow_dispatch runs (for workflow/action changes) have been verified

Initiative Progress (as of 2026-11-25 16:45 UTC): 16 PRs merged so far, with ~18 more PRs needed to be merged to close out all actionable Code Scanning findings (with #41637 disabling Note-level zizmor/self-repository warnings).

Code Scanning Remediation Context (End Goal, Scope & Impact)

If you have concerns with the PR or with the underlying methodology used to generate this, please comment below - they will be addressed by the author not the tooling :)

Summary

Resolves all 3 zizmor/excessive-permissions GitHub Code Scanning alerts across .github/workflows/finalize_release.yml and .github/workflows/deploy_release_candidate_pypi.yaml:

  • .github/workflows/finalize_release.yml (#1537, #1538): Replaces workflow-level contents: write and pull-requests: write with contents: read (push_git_tags and update_master authenticate pushes via inputs.REPO_TOKEN, and no job creates or edits pull requests with GITHUB_TOKEN).
  • .github/workflows/deploy_release_candidate_pypi.yaml (#1528): Adds explicit permissions: contents: read and actions: read (required by download_github_actions_artifacts.py to download RC wheel/sdist workflow artifacts via the GitHub Actions REST API).

(Note: Note-level zizmor/use-trusted-publishing advisories #1797 and #1798 on twine upload require ASF / PyPI OIDC Trusted Publisher registration on pypi.org and are intentionally left out of scope here.)

Verification

@derrickaw

Copy link
Copy Markdown
Collaborator Author

/gemini review

@github-actions github-actions Bot added build size/xs XS: <10 lines changed labels Nov 25, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This PR properly scopes GITHUB_TOKEN permissions to least privilege in .github/workflows/deploy_release_candidate_pypi.yaml and .github/workflows/finalize_release.yml to remediate zizmor/excessive-permissions alerts. The specified permissions accurately match each workflow's runtime requirements.

🔍 General Feedback

  • In deploy_release_candidate_pypi.yaml, granting contents: read and actions: read provides the exact scopes needed for repository checkout and downloading wheel/sdist build artifacts via the GitHub Actions REST API.
  • In finalize_release.yml, downgrading workflow-level permissions from contents: write and pull-requests: write to contents: read is safe because tag and branch pushes authenticate explicitly with inputs.REPO_TOKEN and no PR mutations occur.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@derrickaw derrickaw added ready-for-human Draft PR with all checks passing and all review comments resolved, ready for human review and removed ready-for-human Draft PR with all checks passing and all review comments resolved, ready for human review labels Nov 25, 2026
@derrickaw
derrickaw marked this pull request as ready for review November 25, 2026 19:20
@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @Abacn for label build.
Backup reviewer: damccorm (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@derrickaw
derrickaw merged commit be0bde1 into master Nov 25, 2026
10 checks passed
@derrickaw
derrickaw deleted the codescan/gha-release-workflow-permissions branch November 25, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants