Skip to content

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

Merged
RestartB merged 1 commit intomainfrom
code-scanning-autofix
Mar 19, 2026
Merged

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#153
RestartB merged 1 commit intomainfrom
code-scanning-autofix

Conversation

@RestartB
Copy link
Owner

Potential fix for https://github.com/RestartB/titanium/security/code-scanning/2

In general, the fix is to explicitly declare restricted GITHUB_TOKEN permissions for the workflow (or per-job) instead of relying on inherited defaults. For a Ruff linting workflow that only reads code and dependencies, contents: read is sufficient and aligns with CodeQL’s suggested minimal starting point.

The best way to fix this specific file without changing existing functionality is to add a permissions block at the top workflow level, right after the name: Ruff line (before on:). This will apply to all jobs in the workflow (currently only check) and set the token to read-only for repository contents. No other permissions appear necessary, since the job only checks out code, sets up Python, installs tools/dependencies, and runs Ruff. No extra imports or dependencies are needed; this is a pure YAML configuration change in .github/workflows/ruff.yml.

Concretely:

  • Edit .github/workflows/ruff.yml.

  • Insert:

    permissions:
      contents: read

    between line 1 (name: Ruff) and line 3 (on:), shifting the subsequent lines down.

  • Leave the rest of the workflow unchanged.

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

…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@RestartB RestartB marked this pull request as ready for review March 19, 2026 09:35
@RestartB RestartB merged commit 5af712f into main Mar 19, 2026
4 checks passed
@RestartB RestartB deleted the code-scanning-autofix branch March 19, 2026 14:31
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.

1 participant