Skip to content

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#18

Merged
ialejandro merged 2 commits intofix/security-improvesfrom
fix/alert-autofix-2
Feb 15, 2026
Merged

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#18
ialejandro merged 2 commits intofix/security-improvesfrom
fix/alert-autofix-2

Conversation

@ialejandro
Copy link
Copy Markdown
Member

Potential fix for https://github.com/devops-ia/self-learning-platform/security/code-scanning/2

To fix the problem, define an explicit permissions: block that restricts GITHUB_TOKEN to the least privilege needed. Since this workflow only reads the code (via actions/checkout) and uploads artifacts, and does not write to the repository or modify issues/PRs, we can set contents: read at the top (root) level of the workflow. That setting applies to all jobs that do not override permissions. No job in the shown snippet needs elevated permissions, so a single root-level block is enough.

Concretely, in .github/workflows/lint-test.yml, add:

permissions:
  contents: read

between the name: and on: keys (for example after line 1 or before line 3). This documents the intended permissions and ensures that even if org/repo defaults are broad (read-write) or change in the future, these jobs will only have read access to repository contents. No additional imports, methods, or other definitions are required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Iván Alejandro Marugán <hello@ialejandro.rocks>
@ialejandro ialejandro marked this pull request as ready for review February 15, 2026 15:27
@ialejandro ialejandro changed the base branch from main to fix/security-improves February 15, 2026 15:27
@ialejandro ialejandro merged commit 889d8be into fix/security-improves Feb 15, 2026
@ialejandro ialejandro deleted the fix/alert-autofix-2 branch February 15, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants