Potential fix for code scanning alert no. 4: Workflow does not contain permissions #9
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/Rashed-alothman/TMS/security/code-scanning/4
In general, to fix this type of issue you explicitly declare a
permissions:block either at the workflow root (to apply to all jobs without their own block) or per job, granting only the scopes required. Since none of the shown jobs perform write operations via GitHub’s API, they can safely operate withcontents: read(the minimal suggested by CodeQL), which still allowsactions/checkoutand artifact upload actions to function.The best fix here without changing functionality is to add a top‑level
permissions:block right after thename:oron:section in.github/workflows/ci.yml, settingcontents: read. This will apply to all jobs (test,code-quality,security, anddocker) and limits the defaultGITHUB_TOKENpermissions they receive. No other code changes or imports are required, and no step in the provided snippet depends on broader permissions. If in the future a job needs additional privileges (for example, to comment on PRs), a more permissivepermissions:block can be added to that specific job.Concretely: in
.github/workflows/ci.yml, between thename: TMS CI Pipelineline and theon:block (or just belowon:), insert:This resolves the CodeQL warning while maintaining all existing behavior.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.