Conversation
34c932c to
2fdd7b0
Compare
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/ruff-action@v3 | ||
| with: | ||
| version: "~=0.13.3" | ||
| args: format --check --diff --output-format=github |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
In general, the fix is to explicitly declare the minimal required GITHUB_TOKEN permissions in the workflow, either at the workflow root (applied to all jobs) or per job. Since both jobs only require read access to repository contents, we can set permissions: contents: read at the top level so both flake8 and ruff-format jobs inherit it.
The best fix without changing functionality is to add a root-level permissions block right after the on: section in .github/workflows/lint.yml. This will constrain the GITHUB_TOKEN for all jobs to read-only repository contents, matching the CodeQL suggestion. No imports or additional methods are needed; this is purely a YAML configuration change.
Concretely, in .github/workflows/lint.yml, after line 3 (pull_request:) and before line 5 (jobs:), insert:
permissions:
contents: readThis documents and enforces least-privilege permissions for the workflow.
| @@ -2,6 +2,9 @@ | ||
| on: | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| flake8: | ||
| runs-on: ubuntu-latest |
There was a problem hiding this comment.
Doesn't it though? >.<
permissions:
contents: read0c8d294 to
91d8f47
Compare
91d8f47 to
799b158
Compare
799b158 to
539ef0d
Compare
539ef0d to
f13330c
Compare
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: 3.9 | ||
| python-version: "3.10" |
There was a problem hiding this comment.
Why only 3.10? It's almost EoL
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.10" |
Pull Request Checklist
I have: