Potential fix for code scanning alert no. 1: Workflow does not contain permissions#267
Draft
Potential fix for code scanning alert no. 1: Workflow does not contain permissions#267
Conversation
…n permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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/smartcontractkit/cre-cli/security/code-scanning/1
In general, the fix is to explicitly define a
permissionsblock for every job (or at the workflow root) so that theGITHUB_TOKENscope is minimized and no job depends on repository/organization defaults. For jobs that only need to read repository contents,contents: readis a good minimal baseline; if they don’t need to write anything or access other resources, no additional scopes are required.For this workflow, several jobs already specify:
However,
ci-lint-miscdoes not declare any permissions. To fix the specific CodeQL finding while keeping functionality unchanged and aligned with least privilege, we should add apermissionsblock underci-lint-miscsimilar to the others but tailored to minimal needs. A safe minimal starting point is:This allows the job’s action to read repository contents if needed, without granting any write or extra privileges. If the called
ci-lint-misccomposite action later requires additional permissions, they can be added explicitly, but based on the information given we should not assume any write requirements.Concretely: in
.github/workflows/pull-request-main.yml, within theci-lint-miscjob definition (lines 33–38), insert apermissions:block betweenruns-on: ubuntu-latestandsteps:. No imports or other files are involved.Suggested fixes powered by Copilot Autofix. Review carefully before merging.