Skip to content

Potential fix for code scanning alert no. 14: Workflow does not contain permissions#1074

Merged
BYVoid merged 1 commit intomasterfrom
alert-autofix-14
Mar 27, 2026
Merged

Potential fix for code scanning alert no. 14: Workflow does not contain permissions#1074
BYVoid merged 1 commit intomasterfrom
alert-autofix-14

Conversation

@BYVoid
Copy link
Copy Markdown
Owner

@BYVoid BYVoid commented Mar 27, 2026

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 set contents: read for 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 the release-pypi job, immediately after the job name, and set contents: 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:

  • Edit .github/workflows/release-pypi.yml.
  • Under jobs:, inside release-pypi:, add:
      permissions:
        contents: read
  • Keep indentation consistent with existing keys (strategy, runs-on, etc.).
  • No other lines need to change.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…in permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@BYVoid BYVoid marked this pull request as ready for review March 27, 2026 02:43
@BYVoid BYVoid merged commit 9317625 into master Mar 27, 2026
31 of 32 checks passed
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>
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.

1 participant