Potential fix for code scanning alert no. 2: Workflow does not contain permissions #46
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/lefty01/ESP32_TTGO_FTMS/security/code-scanning/2
In general, the fix is to explicitly declare a
permissionsblock that scopes the GITHUB_TOKEN to the minimum required rights. For this workflow, only read access to the repository contents is needed, since it performs a checkout and local build but does not write to the repo, create issues, or modify pull requests.The best minimally invasive change is to add a single
permissionsblock at the workflow root (top level, alongsideon:andjobs:) specifyingcontents: read. This will apply to all jobs that do not have their ownpermissionsblock, which includes thebuildjob. No functional behavior of the build steps changes; only the token’s capabilities are reduced. Concretely, in.github/workflows/platformio-ci.yml, insert:between the
on:block and thejobs:block (after line 7, before line 10 in the provided snippet). No imports, methods, or other definitions are needed since this is purely a workflow configuration change.Suggested fixes powered by Copilot Autofix. Review carefully before merging.