Skip to content

Commit 2c3c804

Browse files
authored
fix: tighten workflow permissions and fix uv tool invocations (#459)
* fix: tighten workflow permissions and fix uv tool invocations ## What Move elevated permissions from workflow level to job level across four GitHub Actions workflows (major-version-updater, mark-ready-when-ready, scorecard, stale). Set all workflow-level permissions to contents: read. Fix Makefile to use `python -m` for flake8, mypy, and pytest since they lack console script entry points in the uv venv. Upgrade PyJWT from 2.11.0 to 2.12.1 to address CVE-2026-32597. ## Why Workflow-level permissions apply to all jobs, granting broader access than necessary. Moving write permissions to the specific jobs that need them follows the principle of least privilege. The Makefile commands failed because uv doesn't install console scripts for all packages; invoking via `python -m` ensures the tools are found. PyJWT <= 2.11.0 doesn't validate the RFC 7515 `crit` header parameter, rated HIGH (CVSS 7.5). ## Notes - The scorecard workflow previously used `permissions: read-all` which granted read access to all scopes; now explicitly scoped to only what's needed - The `uv run` to `uv run python -m` change also affects CI since the python-package workflow calls `make lint` and `make test` - PyJWT is a transitive dependency; verify downstream consumers aren't relying on the old crit-header-ignored behavior Signed-off-by: jmeridth <jmeridth@gmail.com> * chore: drop autobuild step of codeql from code review Signed-off-by: jmeridth <jmeridth@gmail.com> --------- Signed-off-by: jmeridth <jmeridth@gmail.com>
1 parent f1b61d1 commit 2c3c804

File tree

8 files changed

+24
-23
lines changed

8 files changed

+24
-23
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ This is a GitHub Action identifies and reports repositories with no activity for
1616
## Repository Structure
1717

1818
- `Makefile`: Contains commands for linting, testing, and other tasks
19-
- `requirements.txt`: Python dependencies for the project
20-
- `requirements-test.txt`: Python dependencies for testing
19+
- `pyproject.toml`: Python dependencies and project configuration
2120
- `README.md`: Project documentation and setup instructions
22-
- `setup.py`: Python package setup configuration
2321
- `test_*.py`: Python test files matching the naming convention for test discovery
2422

2523
## Key Guidelines

.github/workflows/codeql.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ jobs:
5959
# By default, queries listed here will override any specified in a config file.
6060
# Prefix the list here with "+" to use these queries and those in the config file.
6161

62-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
63-
# If this step fails, then you should remove it and run the build manually (see below)
64-
- name: Autobuild
65-
uses: github/codeql-action/autobuild@820e3160e279568db735cee8ed8f8e77a6da7818 # v3.32.6
66-
6762
# ℹ️ Command-line programs to run using the OS shell.
6863
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
6964

.github/workflows/major-version-updater.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ on:
1010
env:
1111
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.ref}}
1212
permissions:
13-
contents: write
13+
contents: read
1414
jobs:
1515
update_tag:
1616
name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.ref }} changes
1717
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
1820
steps:
1921
- name: Harden the runner (Audit all outbound calls)
2022
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1

.github/workflows/mark-ready-when-ready.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ on:
55
types: [opened, edited, labeled, unlabeled, synchronize]
66

77
permissions:
8-
checks: read
9-
contents: write
10-
pull-requests: write
11-
statuses: read
8+
contents: read
129

1310
concurrency:
1411
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
@@ -18,6 +15,11 @@ jobs:
1815
mark-ready:
1916
name: Mark as ready after successful checks
2017
runs-on: ubuntu-latest
18+
permissions:
19+
checks: read
20+
contents: write
21+
pull-requests: write
22+
statuses: read
2123
if: |
2224
contains(github.event.pull_request.labels.*.name, 'Mark Ready When Ready') &&
2325
github.event.pull_request.draft == true

.github/workflows/scorecard.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ on:
1313
push:
1414
branches: [main]
1515

16-
permissions: read-all
16+
permissions:
17+
contents: read
1718

1819
jobs:
1920
analysis:
2021
name: Scorecard analysis
2122
runs-on: ubuntu-latest
2223
permissions:
24+
contents: read
2325
security-events: write
2426
id-token: write
2527

.github/workflows/stale.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ on:
44
- cron: "30 1 * * *"
55

66
permissions:
7-
issues: write
8-
pull-requests: read
7+
contents: read
98

109
jobs:
1110
stale:
1211
runs-on: ubuntu-latest
12+
permissions:
13+
issues: write
14+
pull-requests: read
1315
steps:
1416
- name: Harden the runner (Audit all outbound calls)
1517
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: test
22
test:
3-
uv run pytest -v --cov=. --cov-config=.coveragerc --cov-fail-under=80 --cov-report term-missing
3+
uv run python -m pytest -v --cov=. --cov-config=.coveragerc --cov-fail-under=80 --cov-report term-missing
44

55
.PHONY: clean
66
clean:
@@ -9,10 +9,10 @@ clean:
99
.PHONY: lint
1010
lint:
1111
# stop the build if there are Python syntax errors or undefined names
12-
uv run flake8 . --config=.github/linters/.flake8 --count --select=E9,F63,F7,F82 --show-source
12+
uv run python -m flake8 . --config=.github/linters/.flake8 --count --select=E9,F63,F7,F82 --show-source
1313
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
14-
uv run flake8 . --config=.github/linters/.flake8 --count --exit-zero --max-complexity=15 --max-line-length=150
14+
uv run python -m flake8 . --config=.github/linters/.flake8 --count --exit-zero --max-complexity=15 --max-line-length=150
1515
uv run isort --settings-file=.github/linters/.isort.cfg .
1616
uv run pylint --rcfile=.github/linters/.python-lint --fail-under=9.0 *.py
17-
uv run mypy --config-file=.github/linters/.mypy.ini *.py
17+
uv run python -m mypy --config-file=.github/linters/.mypy.ini *.py
1818
uv run black .

uv.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)