Skip to content

Commit ae31df3

Browse files
hugovkAlexWaygood
andauthored
Add zizmor to pre-commit and fix most findings (#127749)
Co-authored-by: Alex Waygood <[email protected]>
1 parent 8dbdbad commit ae31df3

18 files changed

+89
-28
lines changed

.github/workflows/build.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
- uses: actions/checkout@v4
5959
with:
6060
fetch-depth: 1
61+
persist-credentials: false
6162
- name: Runner image version
6263
run: echo "IMAGE_VERSION=${ImageVersion}" >> "$GITHUB_ENV"
6364
- name: Check Autoconf and aclocal versions
@@ -94,6 +95,8 @@ jobs:
9495
if: needs.check_source.outputs.run_tests == 'true'
9596
steps:
9697
- uses: actions/checkout@v4
98+
with:
99+
persist-credentials: false
97100
- uses: actions/setup-python@v5
98101
with:
99102
python-version: '3.x'
@@ -268,6 +271,8 @@ jobs:
268271
LD_LIBRARY_PATH: ${{ github.workspace }}/multissl/openssl/${{ matrix.openssl_ver }}/lib
269272
steps:
270273
- uses: actions/checkout@v4
274+
with:
275+
persist-credentials: false
271276
- name: Runner image version
272277
run: echo "IMAGE_VERSION=${ImageVersion}" >> "$GITHUB_ENV"
273278
- name: Restore config.cache
@@ -328,6 +333,8 @@ jobs:
328333
PYTHONSTRICTEXTENSIONBUILD: 1
329334
steps:
330335
- uses: actions/checkout@v4
336+
with:
337+
persist-credentials: false
331338
- name: Register gcc problem matcher
332339
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
333340
- name: Install Dependencies
@@ -411,7 +418,7 @@ jobs:
411418
#
412419
# (GH-104097) test_sysconfig is skipped because it has tests that are
413420
# failing when executed from inside a virtual environment.
414-
${{ env.VENV_PYTHON }} -m test \
421+
"${VENV_PYTHON}" -m test \
415422
-W \
416423
-o \
417424
-j4 \
@@ -446,6 +453,8 @@ jobs:
446453
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
447454
steps:
448455
- uses: actions/checkout@v4
456+
with:
457+
persist-credentials: false
449458
- name: Runner image version
450459
run: echo "IMAGE_VERSION=${ImageVersion}" >> "$GITHUB_ENV"
451460
- name: Restore config.cache

.github/workflows/documentation-links.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ on:
1010
- 'Doc/**'
1111
- '.github/workflows/doc.yml'
1212

13-
permissions:
14-
pull-requests: write
15-
1613
concurrency:
1714
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1815
cancel-in-progress: true
1916

2017
jobs:
2118
documentation-links:
2219
runs-on: ubuntu-latest
20+
permissions:
21+
pull-requests: write
22+
2323
steps:
2424
- uses: readthedocs/actions/preview@v1
2525
with:

.github/workflows/jit.yml

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
timeout-minutes: 90
3333
steps:
3434
- uses: actions/checkout@v4
35+
with:
36+
persist-credentials: false
3537
- name: Build tier two interpreter
3638
run: |
3739
./configure --enable-experimental-jit=interpreter --with-pydebug
@@ -85,6 +87,8 @@ jobs:
8587
runner: ${{ github.repository_owner == 'python' && 'ubuntu-24.04-aarch64' || 'ubuntu-24.04' }}
8688
steps:
8789
- uses: actions/checkout@v4
90+
with:
91+
persist-credentials: false
8892
- uses: actions/setup-python@v5
8993
with:
9094
python-version: '3.11'
@@ -138,6 +142,8 @@ jobs:
138142
- 19
139143
steps:
140144
- uses: actions/checkout@v4
145+
with:
146+
persist-credentials: false
141147
- uses: actions/setup-python@v5
142148
with:
143149
python-version: '3.11'

.github/workflows/lint.yml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020

2121
steps:
2222
- uses: actions/checkout@v4
23+
with:
24+
persist-credentials: false
2325
- uses: actions/setup-python@v5
2426
with:
2527
python-version: "3.x"

.github/workflows/mypy.yml

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ jobs:
5151
timeout-minutes: 10
5252
steps:
5353
- uses: actions/checkout@v4
54+
with:
55+
persist-credentials: false
5456
- uses: actions/setup-python@v5
5557
with:
5658
python-version: "3.13"

.github/workflows/require-pr-label.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ on:
44
pull_request:
55
types: [opened, reopened, labeled, unlabeled, synchronize]
66

7-
permissions:
8-
issues: write
9-
pull-requests: write
10-
117
jobs:
128
label-dnm:
139
name: DO-NOT-MERGE
1410
if: github.repository_owner == 'python'
1511
runs-on: ubuntu-latest
12+
permissions:
13+
issues: write
14+
pull-requests: write
1615
timeout-minutes: 10
1716

1817
steps:
@@ -28,6 +27,9 @@ jobs:
2827
name: Unresolved review
2928
if: github.repository_owner == 'python'
3029
runs-on: ubuntu-latest
30+
permissions:
31+
issues: write
32+
pull-requests: write
3133
timeout-minutes: 10
3234

3335
steps:

.github/workflows/reusable-change-detection.yml

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ jobs:
6161
- run: >-
6262
echo '${{ github.event_name }}'
6363
- uses: actions/checkout@v4
64+
with:
65+
persist-credentials: false
6466
- name: Check for source changes
6567
id: check
6668
run: |

.github/workflows/reusable-docs.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ jobs:
2222
env:
2323
branch_base: 'origin/${{ github.event.pull_request.base.ref }}'
2424
branch_pr: 'origin/${{ github.event.pull_request.head.ref }}'
25+
commits: ${{ github.event.pull_request.commits }}
2526
refspec_base: '+${{ github.event.pull_request.base.sha }}:remotes/origin/${{ github.event.pull_request.base.ref }}'
2627
refspec_pr: '+${{ github.event.pull_request.head.sha }}:remotes/origin/${{ github.event.pull_request.head.ref }}'
2728
steps:
2829
- name: 'Check out latest PR branch commit'
2930
uses: actions/checkout@v4
3031
with:
32+
persist-credentials: false
3133
ref: >-
3234
${{
3335
github.event_name == 'pull_request'
@@ -39,15 +41,15 @@ jobs:
3941
if: github.event_name == 'pull_request'
4042
run: |
4143
# Fetch enough history to find a common ancestor commit (aka merge-base):
42-
git fetch origin ${{ env.refspec_pr }} --depth=$(( ${{ github.event.pull_request.commits }} + 1 )) \
44+
git fetch origin "${refspec_pr}" --depth=$(( commits + 1 )) \
4345
--no-tags --prune --no-recurse-submodules
4446
4547
# This should get the oldest commit in the local fetched history (which may not be the commit the PR branched from):
46-
COMMON_ANCESTOR=$( git rev-list --first-parent --max-parents=0 --max-count=1 ${{ env.branch_pr }} )
48+
COMMON_ANCESTOR=$( git rev-list --first-parent --max-parents=0 --max-count=1 "${branch_pr}" )
4749
DATE=$( git log --date=iso8601 --format=%cd "${COMMON_ANCESTOR}" )
4850
4951
# Get all commits since that commit date from the base branch (eg: master or main):
50-
git fetch origin ${{ env.refspec_base }} --shallow-since="${DATE}" \
52+
git fetch origin "${refspec_base}" --shallow-since="${DATE}" \
5153
--no-tags --prune --no-recurse-submodules
5254
- name: 'Set up Python'
5355
uses: actions/setup-python@v5
@@ -69,7 +71,7 @@ jobs:
6971
if: github.event_name == 'pull_request'
7072
run: |
7173
python Doc/tools/check-warnings.py \
72-
--annotate-diff '${{ env.branch_base }}' '${{ env.branch_pr }}' \
74+
--annotate-diff "${branch_base}" "${branch_pr}" \
7375
--fail-if-regression \
7476
--fail-if-improved \
7577
--fail-if-new-news-nit
@@ -81,6 +83,8 @@ jobs:
8183
timeout-minutes: 60
8284
steps:
8385
- uses: actions/checkout@v4
86+
with:
87+
persist-credentials: false
8488
- name: 'Set up Python'
8589
uses: actions/setup-python@v5
8690
with:
@@ -99,6 +103,8 @@ jobs:
99103
timeout-minutes: 60
100104
steps:
101105
- uses: actions/checkout@v4
106+
with:
107+
persist-credentials: false
102108
- uses: actions/cache@v4
103109
with:
104110
path: ~/.cache/pip

.github/workflows/reusable-macos.yml

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
runs-on: ${{ inputs.os }}
3030
steps:
3131
- uses: actions/checkout@v4
32+
with:
33+
persist-credentials: false
3234
- name: Runner image version
3335
run: echo "IMAGE_VERSION=${ImageVersion}" >> "$GITHUB_ENV"
3436
- name: Restore config.cache

.github/workflows/reusable-tsan.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ jobs:
2323
name: 'Thread sanitizer'
2424
runs-on: ubuntu-24.04
2525
timeout-minutes: 60
26+
env:
27+
OPTIONS: ${{ inputs.options }}
28+
SUPPRESSIONS_PATH: ${{ inputs.suppressions_path }}
2629
steps:
2730
- uses: actions/checkout@v4
31+
with:
32+
persist-credentials: false
2833
- name: Runner image version
2934
run: echo "IMAGE_VERSION=${ImageVersion}" >> "$GITHUB_ENV"
3035
- name: Restore config.cache
@@ -47,7 +52,7 @@ jobs:
4752
sudo sysctl -w vm.mmap_rnd_bits=28
4853
- name: TSAN Option Setup
4954
run: |
50-
echo "TSAN_OPTIONS=log_path=${GITHUB_WORKSPACE}/tsan_log suppressions=${GITHUB_WORKSPACE}/${{ inputs.suppressions_path }} handle_segv=0" >> "$GITHUB_ENV"
55+
echo "TSAN_OPTIONS=log_path=${GITHUB_WORKSPACE}/tsan_log suppressions=${GITHUB_WORKSPACE}/${SUPPRESSIONS_PATH} handle_segv=0" >> "$GITHUB_ENV"
5156
echo "CC=clang" >> "$GITHUB_ENV"
5257
echo "CXX=clang++" >> "$GITHUB_ENV"
5358
- name: Add ccache to PATH
@@ -59,7 +64,7 @@ jobs:
5964
save: ${{ github.event_name == 'push' }}
6065
max-size: "200M"
6166
- name: Configure CPython
62-
run: ${{ inputs.options }}
67+
run: "${OPTIONS}"
6368
- name: Build CPython
6469
run: make -j4
6570
- name: Display build info

.github/workflows/reusable-ubuntu.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
TERM: linux
2929
steps:
3030
- uses: actions/checkout@v4
31+
with:
32+
persist-credentials: false
3133
- name: Register gcc problem matcher
3234
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
3335
- name: Install dependencies
@@ -94,7 +96,7 @@ jobs:
9496
if: ${{ !inputs.free-threading }}
9597
run: >-
9698
python Tools/build/check_warnings.py
97-
--compiler-output-file-path=${{ env.CPYTHON_BUILDDIR }}/compiler_output_ubuntu.txt
99+
--compiler-output-file-path="${CPYTHON_BUILDDIR}/compiler_output_ubuntu.txt"
98100
--warning-ignore-file-path "${GITHUB_WORKSPACE}/Tools/build/.warningignore_ubuntu"
99101
--compiler-output-type=gcc
100102
--fail-on-regression

.github/workflows/reusable-wasi.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
2121
steps:
2222
- uses: actions/checkout@v4
23+
with:
24+
persist-credentials: false
2325
# No problem resolver registered as one doesn't currently exist for Clang.
2426
- name: "Install wasmtime"
2527
uses: bytecodealliance/actions/wasmtime/setup@v1
@@ -34,9 +36,9 @@ jobs:
3436
- name: "Install WASI SDK" # Hard-coded to x64.
3537
if: steps.cache-wasi-sdk.outputs.cache-hit != 'true'
3638
run: |
37-
mkdir ${{ env.WASI_SDK_PATH }} && \
38-
curl -s -S --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{ env.WASI_SDK_VERSION }}/wasi-sdk-${{ env.WASI_SDK_VERSION }}.0-x86_64-linux.tar.gz | \
39-
tar --strip-components 1 --directory ${{ env.WASI_SDK_PATH }} --extract --gunzip
39+
mkdir "${WASI_SDK_PATH}" && \
40+
curl -s -S --location "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz" | \
41+
tar --strip-components 1 --directory "${WASI_SDK_PATH}" --extract --gunzip
4042
- name: "Configure ccache action"
4143
uses: hendrikmuhs/[email protected]
4244
with:
@@ -72,6 +74,6 @@ jobs:
7274
- name: "Make host"
7375
run: python3 Tools/wasm/wasi.py make-host
7476
- name: "Display build info"
75-
run: make --directory ${{ env.CROSS_BUILD_WASI }} pythoninfo
77+
run: make --directory "${CROSS_BUILD_WASI}" pythoninfo
7678
- name: "Test"
77-
run: make --directory ${{ env.CROSS_BUILD_WASI }} test
79+
run: make --directory "${CROSS_BUILD_WASI}" test

.github/workflows/reusable-windows-msi.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ jobs:
1717
runs-on: windows-latest
1818
timeout-minutes: 60
1919
env:
20+
ARCH: ${{ inputs.arch }}
2021
IncludeFreethreaded: true
2122
steps:
2223
- uses: actions/checkout@v4
24+
with:
25+
persist-credentials: false
2326
- name: Build CPython installer
24-
run: .\Tools\msi\build.bat --doc -${{ inputs.arch }}
27+
run: .\Tools\msi\build.bat --doc -"${ARCH}"

.github/workflows/reusable-windows.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,30 @@ jobs:
2626
name: 'build and test (${{ inputs.arch }})'
2727
runs-on: ${{ inputs.os }}
2828
timeout-minutes: 60
29+
env:
30+
ARCH: ${{ inputs.arch }}
2931
steps:
3032
- uses: actions/checkout@v4
33+
with:
34+
persist-credentials: false
3135
- name: Register MSVC problem matcher
3236
if: inputs.arch != 'Win32'
3337
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
3438
- name: Build CPython
3539
run: >-
3640
.\\PCbuild\\build.bat
3741
-e -d -v
38-
-p ${{ inputs.arch }}
42+
-p "${ARCH}"
3943
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
44+
shell: bash
4045
- name: Display build info # FIXME(diegorusso): remove the `if`
4146
if: inputs.arch != 'arm64'
4247
run: .\\python.bat -m test.pythoninfo
4348
- name: Tests # FIXME(diegorusso): remove the `if`
4449
if: inputs.arch != 'arm64'
4550
run: >-
4651
.\\PCbuild\\rt.bat
47-
-p ${{ inputs.arch }}
52+
-p "${ARCH}"
4853
-d -q --fast-ci
4954
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
55+
shell: bash

.github/workflows/stale.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ on:
44
schedule:
55
- cron: "0 */6 * * *"
66

7-
permissions:
8-
pull-requests: write
9-
107
jobs:
118
stale:
129
if: github.repository_owner == 'python'
1310

1411
runs-on: ubuntu-latest
12+
permissions:
13+
pull-requests: write
1514
timeout-minutes: 10
1615

1716
steps:

.github/workflows/verify-ensurepip-wheels.yml

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
timeout-minutes: 10
2727
steps:
2828
- uses: actions/checkout@v4
29+
with:
30+
persist-credentials: false
2931
- uses: actions/setup-python@v5
3032
with:
3133
python-version: '3'

.github/zizmor.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Configuration for the zizmor static analysis tool, run via pre-commit in CI
2+
# https://woodruffw.github.io/zizmor/configuration/
3+
rules:
4+
dangerous-triggers:
5+
ignore:
6+
- documentation-links.yml

0 commit comments

Comments
 (0)