Skip to content

[CI] Add Workflow permissions to PR tests#13233

Merged
sayakpaul merged 1 commit intomainfrom
alert-autofix-2147
Mar 9, 2026
Merged

[CI] Add Workflow permissions to PR tests#13233
sayakpaul merged 1 commit intomainfrom
alert-autofix-2147

Conversation

@DN6
Copy link
Copy Markdown
Collaborator

@DN6 DN6 commented Mar 9, 2026

Potential fix for https://github.com/huggingface/diffusers/security/code-scanning/2147

In general, the fix is to explicitly set a permissions block in the workflow (at the top level or per job) so that GITHUB_TOKEN has only the minimal required scopes. Since all shown steps only need to read repository contents and do not interact with issues, pull requests, or other write-requiring APIs, the safest minimal configuration is permissions: contents: read at the workflow root, which applies to all jobs.

The best fix here, without changing existing functionality, is to add a top-level permissions section after the on: block (or before concurrency:), so every job gets read-only access to repository contents. No job currently appears to need write access, so this should not break anything. Concretely, in .github/workflows/pr_tests.yml, insert:

permissions:
  contents: read

between the on: block ending at line 17–18 and the concurrency: block starting at line 19. No imports or additional methods are needed, since this is purely YAML configuration.

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

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@DN6 DN6 marked this pull request as ready for review March 9, 2026 11:39
@DN6 DN6 changed the title Potential fix for code scanning alert no. 2147: Workflow does not contain permissions [CI] Add Workflow permissions to PR tests Mar 9, 2026
@DN6 DN6 requested a review from sayakpaul March 9, 2026 12:03
@sayakpaul sayakpaul merged commit 8ea908f into main Mar 9, 2026
11 of 12 checks passed
@sayakpaul sayakpaul deleted the alert-autofix-2147 branch March 9, 2026 12:23
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.

2 participants