Skip to content

Commit 39c3da5

Browse files
committed
ci: security fixes in github actions as suggested by zizmor
1 parent 8b44dc5 commit 39c3da5

10 files changed

Lines changed: 153 additions & 43 deletions

.github/workflows/tidy3d-docs-sync-readthedocs-repo.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ on:
1818
- 'v*'
1919
- 'demo/*'
2020

21+
permissions:
22+
contents: read
23+
2124
jobs:
2225
extract_branch_or_tag:
2326
outputs:
@@ -46,6 +49,7 @@ jobs:
4649
fetch-depth: 0
4750
ref: ${{ needs.extract_branch_or_tag.outputs.ref_name }}
4851
fetch-tags: true
52+
persist-credentials: false
4953

5054
- name: push-mirror-repo
5155
env:

.github/workflows/tidy3d-python-client-daily.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ on:
66
- cron: '0 5 * * *' # Runs at 5am UTC
77

88
permissions:
9-
contents: write
10-
pull-requests: write
9+
contents: read
1110

1211
jobs:
1312
update-lockfile:
1413
uses: ./.github/workflows/tidy3d-python-client-update-lockfile.yml
14+
permissions:
15+
contents: write
16+
pull-requests: write
1517
with:
1618
run-workflow: true
17-
secrets: inherit
19+
secrets:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1821

1922
submodule-tests:
2023
uses: ./.github/workflows/tidy3d-python-client-submodules-test.yml
2124
with:
2225
run-workflow: true
23-
secrets: inherit

.github/workflows/tidy3d-python-client-develop-cli.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
- develop
1010
- latest
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
test-dev-commands:
1417
strategy:
@@ -23,6 +26,7 @@ jobs:
2326
ref: develop
2427
fetch-depth: 1
2528
submodules: false
29+
persist-credentials: false
2630

2731
- name: Set up Python
2832
uses: actions/setup-python@v5
@@ -58,7 +62,7 @@ jobs:
5862
# ----- install & configure poetry -----
5963
#----------------------------------------------
6064
- name: Install Poetry
61-
uses: snok/install-poetry@v1
65+
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
6266
with:
6367
version: 1.8.2
6468
virtualenvs-create: true

.github/workflows/tidy3d-python-client-release.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: "public/tidy3d/python-client-release"
22

3-
permissions:
4-
contents: write
5-
63
on:
74
push:
85
tags:
96
- 'v*.*.*'
107

8+
permissions:
9+
contents: read
10+
1111
jobs:
1212
test-latest-submodules:
1313
runs-on: ubuntu-latest
@@ -19,6 +19,7 @@ jobs:
1919
submodules: 'recursive'
2020
# This fetches only a single branch by default, so additional fetch is needed
2121
fetch-depth: 0 # Optionally, set to 0 to fetch all history for all branches and tags
22+
persist-credentials: false
2223

2324
- name: Initialize and update submodule
2425
run: |
@@ -78,16 +79,21 @@ jobs:
7879
- uses: actions/checkout@v4
7980
with:
8081
ref: ${{ github.ref }}
82+
persist-credentials: false
8183
- name: Exit if any RC release
8284
if: contains(github.ref, 'rc') == false
83-
uses: everlytic/branch-merge@1.1.2
85+
uses: everlytic/branch-merge@c4a244dc23143f824ae6c022a10732566cb8e973 # v1.1.2
86+
permissions:
87+
contents: write
8488
with:
8589
github_token: ${{ secrets.GH_PAT }}
8690
source_ref: ${{ github.ref }}
8791
target_branch: "latest"
8892
commit_message_template: ':tada: RELEASE: Merged {source_ref} into target {target_branch}'
8993
- name: Release
90-
uses: softprops/action-gh-release@v1
94+
permissions:
95+
contents: write
96+
uses: softprops/action-gh-release@aec2ec56f94eb8180ceec724245f64ef008b89f5 # v2.4.0
9197
with:
9298
generate_release_notes: true
9399
env:
@@ -98,27 +104,33 @@ jobs:
98104
- uses: actions/checkout@v4
99105
with:
100106
ref: ${{ github.ref }}
107+
persist-credentials: false
101108
- uses: actions/setup-python@v2
102109
- name: Install dependencies
103110
run: |
104111
python -m pip install --upgrade pip
105112
python -m pip install setuptools wheel twine build
106113
- name: Build and publish
114+
permissions:
115+
contents: write
107116
env:
108117
TWINE_USERNAME: __token__
109118
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
110-
run: |
119+
run: | # zizmor: ignore[use-trusted-publishing]
111120
python -m build
112-
python -m twine upload --repository pypi dist/*
121+
python -m twine upload --repository pypi dist/*
113122
sync_to_develop:
114123
runs-on: ubuntu-latest
115124
steps:
116125
- uses: actions/checkout@v4
117126
with:
118127
ref: "latest"
128+
persist-credentials: false
119129
- name: Exit if any RC release
120130
if: contains(github.ref, 'rc') == false
121-
uses: everlytic/branch-merge@1.1.2
131+
uses: everlytic/branch-merge@c4a244dc23143f824ae6c022a10732566cb8e973 # v1.1.5
132+
permissions:
133+
contents: write
122134
with:
123135
github_token: ${{ secrets.GH_PAT }}
124136
source_ref: "latest"

.github/workflows/tidy3d-python-client-submodules-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ on:
2222
type: boolean
2323
default: true
2424

25+
permissions:
26+
contents: read
27+
2528
jobs:
2629
test-latest-submodules:
2730
runs-on: ubuntu-latest
@@ -33,6 +36,7 @@ jobs:
3336
submodules: 'recursive'
3437
# This fetches only a single branch by default, so additional fetch is needed
3538
fetch-depth: 0 # Optionally, set to 0 to fetch all history for all branches and tags
39+
persist-credentials: false
3640

3741
- name: Initialize and update submodule
3842
run: |

0 commit comments

Comments
 (0)