Skip to content

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#2360

Merged
Simek merged 1 commit intomainfrom
alert-autofix-2
Apr 8, 2026
Merged

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#2360
Simek merged 1 commit intomainfrom
alert-autofix-2

Conversation

@Simek
Copy link
Copy Markdown
Member

@Simek Simek commented Apr 8, 2026

Potential fix for https://github.com/react-native-community/directory/security/code-scanning/2

To fix the problem, explicitly restrict the GITHUB_TOKEN permissions for this workflow/job so it does not rely on potentially read‑write repository defaults. Because this workflow only needs to check out code and run an external deploy command authenticated by VERCEL_TOKEN, it should only require contents: read. This aligns with the CodeQL suggestion and the principle of least privilege.

The best fix is to add a permissions block setting contents: read. We can add it at the workflow root so it applies to all jobs (only build exists here), without altering existing functionality. Concretely, in .github/workflows/code-deploy-preview.yml, insert:

permissions:
  contents: read

between the on: block and the jobs: block (i.e., after line 5 and before line 7). No new imports or other definitions are needed; we are only changing the workflow 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>
@Simek Simek marked this pull request as ready for review April 8, 2026 10:20
@Simek Simek merged commit 401e6c1 into main Apr 8, 2026
5 checks passed
@Simek Simek deleted the alert-autofix-2 branch April 8, 2026 10:35
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