Skip to content

Commit 628fb7a

Browse files
committed
ci: harden GitHub Actions workflows and add zizmor scan
Adds a CI job that runs the zizmor static analyzer over the workflow files under .github/, and applies the corresponding hardening so the existing workflows pass the audit: - add persist-credentials: false to every actions/checkout step that lacked it - narrow top-level permissions: read-all to permissions: contents: read - add a 7-day cooldown to the dependabot update entries This is a CI/configuration-only change; no library code, tests, or documentation are affected.
1 parent fe1455e commit 628fb7a

10 files changed

Lines changed: 64 additions & 8 deletions

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ updates:
55
schedule:
66
interval: "weekly"
77
day: "saturday"
8+
cooldown:
9+
default-days: 7
810
rebase-strategy: "disabled"
911
labels: ["autoupdate"]
1012
groups:
@@ -16,6 +18,8 @@ updates:
1618
schedule:
1719
interval: "weekly"
1820
day: "saturday"
21+
cooldown:
22+
default-days: 7
1923
rebase-strategy: "disabled"
2024
labels: ["autoupdate"]
2125
groups:

.github/workflows/build-with-clang.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66
- master
77
pull_request:
88

9-
permissions: read-all
9+
permissions:
10+
contents: read
1011

1112
jobs:
1213
build-with-clang:
@@ -51,6 +52,7 @@ jobs:
5152
- name: Checkout repo
5253
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
5354
with:
55+
persist-credentials: false
5456
fetch-depth: 0
5557

5658
- name: Install mkl-service dependencies

.github/workflows/build-with-standard-clang.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ on:
55
push:
66
branches: [master]
77

8-
permissions: read-all
8+
permissions:
9+
contents: read
910

1011
jobs:
1112
build-with-standard-clang:
@@ -42,6 +43,7 @@ jobs:
4243
- name: Checkout repo
4344
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
4445
with:
46+
persist-credentials: false
4547
fetch-depth: 0
4648

4749
- name: Install mkl-service dependencies

.github/workflows/build_pip.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66
- master
77
pull_request:
88

9-
permissions: read-all
9+
permissions:
10+
contents: read
1011

1112
jobs:
1213
build:
@@ -27,6 +28,7 @@ jobs:
2728
steps:
2829
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2930
with:
31+
persist-credentials: false
3032
fetch-depth: 0
3133

3234
- uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1

.github/workflows/conda-build-test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ on:
2929
default: false
3030
type: boolean
3131

32-
permissions: read-all
32+
permissions:
33+
contents: read
3334

3435
env:
3536
module-name: mkl
@@ -69,6 +70,7 @@ jobs:
6970
- name: Checkout repo
7071
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
7172
with:
73+
persist-credentials: false
7274
fetch-depth: 0
7375

7476
- name: Setup miniconda

.github/workflows/conda-package-cf.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66
- master
77
pull_request:
88

9-
permissions: read-all
9+
permissions:
10+
contents: read
1011

1112
concurrency:
1213
group: ${{ github.workflow }}-${{ github.ref }}

.github/workflows/conda-package.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66
- master
77
pull_request:
88

9-
permissions: read-all
9+
permissions:
10+
contents: read
1011

1112
concurrency:
1213
group: ${{ github.workflow }}-${{ github.ref }}

.github/workflows/openssf-scorecard.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ on:
1616
branches: [ "master" ]
1717

1818
# Declare default permissions as read only.
19-
permissions: read-all
19+
permissions:
20+
contents: read
2021

2122
jobs:
2223
analysis:

.github/workflows/pre-commit.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ on:
55
push:
66
branches: [master]
77

8-
permissions: read-all
8+
permissions:
9+
contents: read
910

1011
jobs:
1112
pre-commit:
@@ -15,6 +16,7 @@ jobs:
1516
- name: Checkout repo
1617
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
1718
with:
19+
persist-credentials: false
1820
# use commit hash to make "no-commit-to-branch" check passing
1921
ref: ${{ github.sha }}
2022

.github/workflows/zizmor.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Security scan of GitHub Actions workflows (zizmor)
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
permissions: {}
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
zizmor:
17+
name: Scan GitHub Actions workflows
18+
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 10
21+
22+
permissions:
23+
contents: read # needed to clone the repo
24+
25+
steps:
26+
- name: Checkout mkl-service repo
27+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
28+
with:
29+
persist-credentials: false
30+
31+
- name: Run zizmor
32+
uses: zizmorcore/zizmor-action@70fb788f84895a7701f5643d103d587e460b5c99 # v0.6.3
33+
with:
34+
# Low/informational template-injection notes come from internally-defined
35+
# values (no external input), so they are reported as annotations but do not gate CI
36+
min-severity: medium
37+
advanced-security: false
38+
annotations: true
39+
inputs: .github/

0 commit comments

Comments
 (0)