Skip to content

Potential fix for code scanning alert no. 3: Workflow does not contain permissions#2359

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

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

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/3

In general, the problem is fixed by explicitly specifying a permissions block in the workflow (either at the root level or inside each job) to scope GITHUB_TOKEN to the minimum required privileges, typically contents: read for CI jobs that only need to read the repository. This overrides potentially broader repository/organization defaults.

For this workflow, the best fix without changing existing behavior is to add a root-level permissions section right after the name (or before jobs:) that grants only contents: read. The job only checks out the code, installs dependencies, and runs tests/lint/build, and the third-party action that receives the GITHUB_TOKEN only needs to read repository contents to compare lockfiles, so contents: read is sufficient and safe. No other permissions (like pull-requests: write) are needed, since the workflow does not modify PRs or issues. The only file to edit is .github/workflows/code-lint-and-test.yml, adding a few lines; no imports or other code changes are required.

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 79845f6 into main Apr 8, 2026
5 checks passed
@Simek Simek deleted the alert-autofix-3 branch April 8, 2026 10:33
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