Potential fix for code scanning alert no. 14: Workflow does not contain permissions#1074
Merged
Potential fix for code scanning alert no. 14: Workflow does not contain permissions#1074
Conversation
…in permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
BYVoid
pushed a commit
that referenced
this pull request
Mar 27, 2026
Following the pattern from PR #1074, add `permissions: contents: read` to all workflow jobs that only need read access. The release-winget workflow already has appropriate write permissions. https://claude.ai/code/session_01PH4HxLHfpWeSNSS1MvK6f9
BYVoid
added a commit
that referenced
this pull request
Mar 27, 2026
) Following the pattern from PR #1074, add `permissions: contents: read` to all workflow jobs that only need read access. The release-winget workflow already has appropriate write permissions. https://claude.ai/code/session_01PH4HxLHfpWeSNSS1MvK6f9 Co-authored-by: Claude <noreply@anthropic.com>
1 task
3 tasks
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.
Potential fix for https://github.com/BYVoid/OpenCC/security/code-scanning/14
In general, the fix is to add an explicit
permissions:block that restricts the GITHUB_TOKEN to the minimal scopes required. For this workflow, the steps only need to read repository contents (for checkout) and then use secrets to publish to PyPI. They do not need to write to the repo or manage issues/PRs/releases. Therefore, we can setcontents: readfor the job (or at the workflow root). This documents the intent and prevents accidental grant of broader privileges.The best minimal change without altering behavior is to add a
permissions:key under therelease-pypijob, immediately after the job name, and setcontents: read. That ensures that only this job’s token is restricted, without affecting any other jobs (there are no others in the snippet, but this is still clean and localized). No additional imports or tools are needed; it is just a YAML configuration change in.github/workflows/release-pypi.yml.Concretely:
.github/workflows/release-pypi.yml.jobs:, insiderelease-pypi:, add:strategy,runs-on, etc.).Suggested fixes powered by Copilot Autofix. Review carefully before merging.