Potential fix for code scanning alert no. 1: Workflow does not contain permissions#37
Closed
Dargon789 wants to merge 0 commit into
Closed
Potential fix for code scanning alert no. 1: Workflow does not contain permissions#37Dargon789 wants to merge 0 commit into
Dargon789 wants to merge 0 commit into
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds an explicit, least-privilege permissions block to the check-permissions job in the Claude GitHub Actions workflow to satisfy a code scanning alert without altering job behavior. Flow diagram for check-permissions job with explicit read-only tokenflowchart TD
A[Workflow_triggered] --> B[Start_check-permissions_job]
B --> C[Provision_runner_ubuntu-latest]
C --> D[Issue_GITHUB_TOKEN_with_permissions_contents_read]
D --> E[Run_actions/github-script_v7]
E --> F[Call_GitHub_API_repos_getCollaboratorPermissionLevel]
F --> G[Set_output_has-permission]
G --> H[Downstream_jobs_read_has-permission_output]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Owner
Author
|
@Mergifyio refresh |
✅ Pull request refreshed |
cf9b119 to
d1d8d9b
Compare
Owner
Author
|
@Mergifyio refresh |
✅ Pull request refreshed |
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/Dargon789/account/security/code-scanning/1
In general, to fix this type of issue you add an explicit
permissionsblock either at the workflow root or on each job, setting the least privileges required. Jobs that only read repository metadata or usegithub-scriptfor read-only queries typically only needcontents: read(and sometimes no special scopes beyond the defaultmetadata: read).For this workflow, the
claude-assistantjob already has explicit (and intentionally broad) permissions, so we should not change that job. The flagged job ischeck-permissions, which usesactions/github-script@v7to callgithub.rest.repos.getCollaboratorPermissionLevel. That requires read access to repository contents/metadata, but no write access. The best fix is to add apermissionsblock undercheck-permissionswith a minimal scope, e.g.contents: read. We keep everything else unchanged. Concretely, in.github/workflows/claude-code.ymlunderjobs:, insidecheck-permissions:and alongsidename:,runs-on:, etc., add:This ensures the
GITHUB_TOKENfor that job is limited to read-only repository contents, satisfying CodeQL and the principle of least privilege without affecting current functionality.Suggested fixes powered by Copilot Autofix. Review carefully before merging.
Summary by Sourcery
Restrict the GitHub Actions workflow job token to read-only repository contents to address a code scanning permissions alert.
Bug Fixes:
CI: