Skip to content

Commit 8495cc9

Browse files
dfremontlola831
andauthored
Use zizmor to scan for GHA security problems (#320)
* apply GHA security improvements suggested by zizmor * run zizmor in CI * Update GH_REF reference in check_simulator_version_updates job --------- Co-authored-by: Lola Marrero <[email protected]>
1 parent dcd0213 commit 8495cc9

File tree

6 files changed

+52
-3
lines changed

6 files changed

+52
-3
lines changed

.github/workflows/check-formatting.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
steps:
1212
- name: Checkout code
1313
uses: actions/checkout@v3
14+
with:
15+
persist-credentials: false
1416

1517
- name: Run black to check formatting
1618
uses: psf/black@stable

.github/workflows/on-call-reminder.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ jobs:
1212
steps:
1313
- name: Checkout code
1414
uses: actions/checkout@v3
15+
with:
16+
persist-credentials: false
1517

1618
- name: Set up Python
1719
uses: actions/setup-python@v4

.github/workflows/run-coverage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ jobs:
3333
if: inputs.ref != ''
3434
with:
3535
ref: ${{ inputs.ref }}
36+
persist-credentials: false
3637

3738
- name: Checkout current branch
3839
uses: actions/checkout@v3
3940
if: inputs.ref == ''
4041
with:
4142
ref: ${{ github.ref }}
43+
persist-credentials: false
4244

4345
- name: Set up Python ${{ matrix.python-version }}
4446
uses: actions/setup-python@v4

.github/workflows/run-simulators.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@ jobs:
8888
HOSTNAME: ${{ secrets.SSH_HOST }}
8989
USER_NAME: ${{ secrets.SSH_USERNAME }}
9090
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
91+
GH_REF: ${{ github.ref }}
9192
run: |
9293
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
93-
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} '
94+
ssh -o StrictHostKeyChecking=no -o SendEnv=GH_REF -i private_key ${USER_NAME}@${HOSTNAME} '
9495
cd /home/ubuntu/actions/ &&
9596
rm -rf Scenic &&
96-
git clone --branch $(basename "${{ github.ref }}") --single-branch https://[email protected]/BerkeleyLearnVerify/Scenic.git &&
97+
git clone --branch $(basename "$GH_REF") --single-branch https://[email protected]/BerkeleyLearnVerify/Scenic.git &&
9798
cd Scenic &&
9899
python3 -m venv venv &&
99100
source venv/bin/activate &&

.github/workflows/run-tests.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ jobs:
4747
if: inputs.ref != ''
4848
with:
4949
ref: ${{ inputs.ref }}
50+
persist-credentials: false
5051

5152
- name: Checkout current branch
5253
uses: actions/checkout@v3
5354
if: inputs.ref == ''
5455
with:
5556
ref: ${{ github.ref }}
57+
persist-credentials: false
5658

5759
- name: Set up Python ${{ matrix.python-version }}
5860
uses: actions/setup-python@v4
@@ -69,5 +71,8 @@ jobs:
6971
python -m pip install -e ".[test-full]"
7072
7173
- name: Run pytest
74+
env:
75+
TEST_OPTIONS: ${{ inputs.options || (matrix.slow && '--no-graphics' || '--fast --no-graphics') }}
76+
shell: sh
7277
run: |
73-
pytest ${{ inputs.options || (matrix.slow && '--no-graphics' || '--fast --no-graphics') }}
78+
pytest ${TEST_OPTIONS}

.github/workflows/zizmor.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: GitHub Actions Security Analysis with zizmor 🌈
2+
# https://woodruffw.github.io/zizmor
3+
4+
on:
5+
push:
6+
branches: ["main"]
7+
pull_request:
8+
branches: ["**"]
9+
10+
jobs:
11+
zizmor:
12+
name: zizmor latest via PyPI
13+
runs-on: ubuntu-latest
14+
permissions:
15+
security-events: write
16+
# required for workflows in private repositories
17+
contents: read
18+
actions: read
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
persist-credentials: false
24+
25+
- name: Install the latest version of uv
26+
uses: astral-sh/setup-uv@v4
27+
28+
- name: Run zizmor 🌈
29+
run: uvx zizmor --format sarif . > results.sarif
30+
env:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Upload SARIF file
34+
uses: github/codeql-action/upload-sarif@v3
35+
with:
36+
sarif_file: results.sarif
37+
category: zizmor

0 commit comments

Comments
 (0)