豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Add top level permissions to workflows#14501

Merged
truggeri merged 7 commits intomainfrom
truggeri/workflow_permissions
Mar 23, 2026
Merged

Add top level permissions to workflows#14501
truggeri merged 7 commits intomainfrom
truggeri/workflow_permissions

Conversation

@truggeri
Copy link
Copy Markdown
Contributor

@truggeri truggeri commented Mar 20, 2026

What are you trying to accomplish?

There are open code scanning alerts related to "Token-Permissions" where there's not a top level permissions block in some workflows in this repo. This was fixed for a single workflow in #14479.

How will you know you've accomplished your goal?

We will be successful when all the code scanning alerts close.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@truggeri truggeri self-assigned this Mar 20, 2026
@truggeri truggeri marked this pull request as ready for review March 23, 2026 22:02
@truggeri truggeri requested a review from a team as a code owner March 23, 2026 22:02
Copilot AI review requested due to automatic review settings March 23, 2026 22:02
@truggeri truggeri enabled auto-merge March 23, 2026 22:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Code Scanning “Token-Permissions” alerts by adding explicit top-level permissions blocks to GitHub Actions workflows and then scoping per-job permissions to the minimum needed.

Changes:

  • Add top-level permissions: {} to multiple workflows to avoid relying on implicit defaults.
  • Add/adjust job-level permissions (e.g., contents: read, actions: read, security-events: write) where required.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/smoke.yml Adds permissions blocks (but current placement makes permissions part of env, which is incorrect).
.github/workflows/images-updater-core.yml Adds top-level permissions: {}; job already sets required write scopes for GHCR/cosign.
.github/workflows/images-branch.yml Adds top-level permissions: {} and tightens job permissions for approval job.
.github/workflows/gems-release-to-rubygems.yml Adds top-level permissions: {}; job keeps needed id-token: write.
.github/workflows/gems-bump-version.yml Adds top-level permissions: {} and sets minimal job permissions.
.github/workflows/copilot-setup-steps.yml Adds top-level permissions: {}; job remains contents: read.
.github/workflows/codeql-analysis.yml Adds top-level permissions: {}; job keeps security-events: write.
.github/workflows/ci.yml Adds top-level permissions: {} and ensures each job has contents: read.
.github/workflows/check-sorbet-typing-mode.yml Adds top-level permissions: {}; job remains contents: read.

@@ -15,9 +15,13 @@ concurrency:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SMOKE_TEST_BRANCH: ${{ vars.SMOKE_TEST_BRANCH || 'main' }}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

permissions: {} is indented under env: which makes it an environment variable entry rather than the workflow-level permissions block. This likely breaks the workflow syntax (env values must be strings) and also won’t address the Token-Permissions alert. Move permissions: {} out to the top level (same indentation as env:/jobs:).

Suggested change
SMOKE_TEST_BRANCH: ${{ vars.SMOKE_TEST_BRANCH || 'main' }}
SMOKE_TEST_BRANCH: ${{ vars.SMOKE_TEST_BRANCH || 'main' }}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think that's right

@truggeri truggeri merged commit d9bc1b4 into main Mar 23, 2026
170 of 171 checks passed
@truggeri truggeri deleted the truggeri/workflow_permissions branch March 23, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants