Potential fix for code scanning alert no. 23: Workflow does not contain permissions #61
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/Cattn/Maple/security/code-scanning/23
In general, the fix is to add an explicit
permissionsblock that grants only the minimal scopes needed by the workflow. This can be added either at the top level of the workflow (applies to all jobs) or on the specific job that CodeQL flagged. Since this workflow primarily checks out code, installs Node dependencies, runs format/lint, and then commits and pushes formatting changes, it only needs permission to read and write repository contents; it does not need broader permissions like actions, issues, or pull-requests.The best fix without changing existing functionality is to add a
permissionsblock under thelint_formatjob specifyingcontents: write. This will ensure the job still has enough access to push commits while restricting GITHUB_TOKEN to repository contents only. You could also addpermissionsat the workflow root, but because CodeQL flagged a specific job and this workflow currently has only one job, putting the block underjobs.lint_formatis straightforward and precise. Concretely, in.github/workflows/lint-format.yml, insert apermissions:mapping underlint_format:(line 9) and aboveruns-on:(line 10), with proper indentation:No additional imports, methods, or definitions are needed since this is purely a YAML configuration change.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.
Note
Sets explicit minimal GitHub Actions permissions for the lint/format workflow.
permissions: contents: writeunderjobs.lint_formatin.github/workflows/lint-format.ymlto scopeGITHUB_TOKENappropriately while allowing commit/push of formatting changesWritten by Cursor Bugbot for commit cefcc89. This will update automatically on new commits. Configure here.