Skip to content

Commit c5d8242

Browse files
authored
ci: address all zizmor lints (#15258)
Fixes all zizmor lints which are the majority of GH code scan issues: * Set empty `permissions: {}` for all workflows * Specify permissions needed explicitly for each job * Use `name:` keys for all workflows, jobs, and steps * Use `persist-credentials: false` for all actions/checkout steps * Remove actions expressions from bash blocks, plumb thru `env:`
1 parent 47c1a77 commit c5d8242

9 files changed

+82
-21
lines changed

.github/workflows/label-pull-request.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@ on:
1313
# zizmor: ignore[dangerous-triggers]
1414
- pull_request_target
1515

16+
permissions: {}
17+
1618
jobs:
1719
labeler:
20+
name: Label PRs
1821
# only run on the main Lucene repository.
1922
if: (github.repository == 'apache/lucene')
2023

2124
permissions:
22-
contents: read
23-
pull-requests: write
25+
contents: read # likely not needed for public repository
26+
pull-requests: write # manipulate existing labels
2427

2528
runs-on: ubuntu-latest
2629

2730
steps:
28-
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
31+
- name: Run Labeler action
32+
uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
2933
with:
3034
sync-labels: true

.github/workflows/mark-stale-PRs.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@ on:
1010
# Or run on demand
1111
workflow_dispatch:
1212

13+
permissions: {}
14+
1315
jobs:
1416
stale:
17+
name: Mark stale PRs
1518
runs-on: ubuntu-latest
1619

1720
permissions:
18-
pull-requests: write
21+
pull-requests: write # must comment/label PRs
1922

2023
steps:
21-
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
24+
- name: Run stale PR action
25+
uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
2226
with:
2327
repo-token: ${{ secrets.GITHUB_TOKEN }}
2428

.github/workflows/run-checks-all.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212
- 'main'
1313
- 'branch_10x'
1414

15+
permissions: {}
16+
1517
env:
1618
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
1719

@@ -37,8 +39,13 @@ jobs:
3739
- name: Correct git autocrlf
3840
run: git config --global core.autocrlf false
3941

40-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
41-
- uses: ./.github/actions/prepare-for-build
42+
- name: Checkout repository
43+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
44+
with:
45+
persist-credentials: false
46+
47+
- name: Configure tools
48+
uses: ./.github/actions/prepare-for-build
4249

4350
- name: Install eclint
4451
if: ${{ ! startsWith(matrix.os, 'windows') }}
@@ -72,8 +79,13 @@ jobs:
7279
if: startsWith(matrix.os, 'windows')
7380
run: git config --global core.autocrlf false
7481

75-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
76-
- uses: ./.github/actions/prepare-for-build
82+
- name: Checkout repository
83+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
84+
with:
85+
persist-credentials: false
86+
87+
- name: Configure tools
88+
uses: ./.github/actions/prepare-for-build
7789

7890
- name: Run gradle tests
7991
run: ./gradlew test "-Ptask.times=true" --max-workers 2

.github/workflows/run-checks-mod-analysis-common-hunspell.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ on:
1919
- '.github/workflows/run-checks-mod-analysis-common.yml'
2020
- 'lucene/analysis/common/**'
2121

22+
permissions: {}
23+
2224
env:
2325
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
2426

@@ -30,8 +32,13 @@ jobs:
3032
runs-on: ubuntu-latest
3133

3234
steps:
33-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
34-
- uses: ./.github/actions/prepare-for-build
35+
- name: Checkout repository
36+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
37+
with:
38+
persist-credentials: false
39+
40+
- name: Configure tools
41+
uses: ./.github/actions/prepare-for-build
3542

3643
- name: Run Hunspell regression tests
3744
run: ./gradlew -p lucene/analysis/common -Ptests.hunspell.regressions=true -Ptests.verbose=true test --tests "TestAllDictionaries"

.github/workflows/run-checks-mod-distribution.tests.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ on:
1313
- 'main'
1414
- 'branch_10x'
1515

16+
permissions: {}
17+
1618
env:
1719
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
1820

1921
jobs:
2022
test:
23+
name: Run distribution.tests
2124
timeout-minutes: 15
2225

2326
strategy:
@@ -29,8 +32,13 @@ jobs:
2932
runs-on: ${{ matrix.os }}
3033

3134
steps:
32-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
33-
- uses: ./.github/actions/prepare-for-build
35+
- name: Checkout repository
36+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
37+
with:
38+
persist-credentials: false
39+
40+
- name: Configure tools
41+
uses: ./.github/actions/prepare-for-build
3442

3543
- name: Run 'gradlew lucene/distribution.tests test' (on ${{ matrix.os }})
3644
run: ./gradlew -p lucene/distribution.tests test

.github/workflows/run-checks-python.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ on:
1919
- '.github/workflows/run-checks-python.yml'
2020
- 'dev-tools/scripts/**'
2121

22+
permissions: {}
23+
2224
jobs:
2325
lint:
26+
name: Lint python scripts
2427
timeout-minutes: 15
2528
runs-on: ubuntu-latest
2629

2730
steps:
28-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
31+
- name: Checkout repository
32+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
33+
with:
34+
persist-credentials: false
2935

3036
- name: Setup Python
3137
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0

.github/workflows/run-scheduled-hunspell.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
# 4:13 on Mondays
88
- cron: '13 4 * * 1'
99

10+
permissions: {}
11+
1012
env:
1113
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
1214

@@ -18,8 +20,13 @@ jobs:
1820
runs-on: ubuntu-latest
1921

2022
steps:
21-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
22-
- uses: ./.github/actions/prepare-for-build
23+
- name: Checkout repository
24+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
25+
with:
26+
persist-credentials: false
27+
28+
- name: Configure tools
29+
uses: ./.github/actions/prepare-for-build
2330

2431
- name: Run Hunspell regression tests against latest commits in dictionary repositories
2532
run: >

.github/workflows/run-scheduled-spotless-groovy.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,28 @@ on:
77
# 3:13 on Mondays
88
- cron: '13 4 * * 1'
99

10+
permissions: {}
11+
1012
env:
1113
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
1214

1315
jobs:
1416
test:
1517
name: Check groovy/gradle script formatting compliance
1618
timeout-minutes: 15
17-
1819
runs-on: ubuntu-latest
1920

2021
steps:
21-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
22-
- uses: ./.github/actions/prepare-for-build
22+
- name: Checkout repository
23+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
24+
with:
25+
persist-credentials: false
26+
27+
- name: Configure tools
28+
uses: ./.github/actions/prepare-for-build
2329

24-
- run: >
30+
- name: Run formatter check
31+
run: >
2532
./gradlew
2633
-Plucene.spotlessGradleScripts=true
2734
spotlessGradleScriptsCheck

.github/workflows/run-special-checks-sandbox.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212
- 'main'
1313
- 'branch_10x'
1414

15+
permissions: {}
16+
1517
jobs:
1618
faiss-tests:
1719
name: tests for the Faiss codec (v${{ matrix.faiss-version }} with JDK ${{ matrix.java }} on ${{ matrix.os }})
@@ -37,10 +39,14 @@ jobs:
3739
conda-remove-defaults: 'true'
3840

3941
- name: Install Faiss
40-
run: mamba install faiss-cpu=${{ matrix.faiss-version }}
42+
run: mamba install faiss-cpu="${FAISS_VERSION}"
43+
env:
44+
FAISS_VERSION: ${{ matrix.faiss-version }}
4145

4246
- name: Checkout Lucene
4347
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
48+
with:
49+
persist-credentials: false
4450

4551
- name: Prepare Lucene workspace
4652
uses: ./.github/actions/prepare-for-build

0 commit comments

Comments
 (0)