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.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 6 months ago
In general, to fix this category of issue you add a
permissions:block either at the top (root) of the workflow to apply to all jobs, or under a specific job to apply only there. The block should grant the minimum scopes needed. For workflows that only run checks and do not need to write back to the repository,contents: readis a good baseline. If the reusable workflow needs additional permissions (for example, to update issues or pull requests), those can be added explicitly.For this specific workflow, the simplest and safest change without altering behavior of the reusable workflow is to declare minimal read-only permissions at the workflow root, just under the
name:key and beforeon:. This ensures theGITHUB_TOKENavailable to thecompliancejob (and thus to the called reusable workflow) is constrained to read repository contents by default. If the reusable workflow requires more permissions, they can still be granted there; our change does not prevent that, but documents and constrains the default from this workflow鈥檚 side. Concretely, in.github/workflows/compliance-check.yml, add:between lines 1 and 3. No imports or additional methods are needed, since this is a YAML configuration change only.