Skip to content

Commit ee37b70

Browse files
reberhardt7claude
andcommitted
Fix GitHub Actions workflow security issues (zizmor)
- Fix template injection vulnerabilities by using environment variables instead of inline expressions in shell scripts (docker-stable, release) - Pin third-party actions to full SHA commits (docker-stable) - Add top-level permissions blocks with least-privilege scoping (docker-stable, e2e-test, version-check) - Add persist-credentials: false to all checkout steps - Add zizmor.yml configuration file - Fix missing newlines at end of files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 27a4738 commit ee37b70

File tree

6 files changed

+39
-13
lines changed

6 files changed

+39
-13
lines changed

.github/workflows/docker-stable.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,46 @@ on:
66
description: 'Version to mark as stable (e.g., 1.2.3)'
77
required: true
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
stable:
1114
runs-on: ubuntu-latest
1215
steps:
13-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
17+
with:
18+
persist-credentials: false
1419

1520
- name: Check if version exists in PyPI
1621
id: version_check
22+
env:
23+
INPUT_VERSION: ${{ inputs.version }}
1724
run: |
18-
if ! curl -s -f https://pypi.org/pypi/socketsecurity/${{ inputs.version }}/json > /dev/null; then
19-
echo "Error: Version ${{ inputs.version }} not found on PyPI"
25+
if ! curl -s -f "https://pypi.org/pypi/socketsecurity/${INPUT_VERSION}/json" > /dev/null; then
26+
echo "Error: Version ${INPUT_VERSION} not found on PyPI"
2027
exit 1
2128
fi
22-
echo "Version ${{ inputs.version }} found on PyPI - proceeding with release"
29+
echo "Version ${INPUT_VERSION} found on PyPI - proceeding with release"
2330
2431
- name: Set up QEMU
25-
uses: docker/setup-qemu-action@v3
32+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
2633

2734
- name: Set up Docker Buildx
28-
uses: docker/setup-buildx-action@v3
35+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
2936

3037
- name: Login to Docker Hub with Organization Token
31-
uses: docker/login-action@v3
38+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
3239
with:
3340
username: ${{ secrets.DOCKERHUB_USERNAME }}
3441
password: ${{ secrets.DOCKERHUB_TOKEN }}
3542

3643
- name: Build & Push Stable Docker
37-
uses: docker/build-push-action@v5
44+
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
3845
with:
3946
push: true
4047
platforms: linux/amd64,linux/arm64
4148
tags: socketdev/cli:stable
4249
build-args: |
4350
CLI_VERSION=${{ inputs.version }}
44-
51+

.github/workflows/e2e-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
pull_request:
77
workflow_dispatch:
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
e2e-scan:
1114
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
@@ -14,6 +17,7 @@ jobs:
1417
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
1518
with:
1619
fetch-depth: 0
20+
persist-credentials: false
1721

1822
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
1923
with:
@@ -56,6 +60,7 @@ jobs:
5660
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
5761
with:
5862
fetch-depth: 0
63+
persist-credentials: false
5964

6065
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
6166
with:
@@ -96,6 +101,7 @@ jobs:
96101
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
97102
with:
98103
fetch-depth: 0
104+
persist-credentials: false
99105

100106
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
101107
with:

.github/workflows/pr-preview.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
1616
with:
1717
fetch-depth: 0
18+
persist-credentials: false
1819
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
1920
with:
2021
python-version: '3.13'

.github/workflows/release.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
1414
with:
1515
fetch-depth: 0
16+
persist-credentials: false
1617
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
1718
with:
1819
python-version: '3.13'
@@ -26,11 +27,13 @@ jobs:
2627
2728
- name: Get Version
2829
id: version
30+
env:
31+
REF_NAME: ${{ github.ref_name }}
2932
run: |
3033
RAW_VERSION=$(hatch version)
3134
echo "VERSION=$RAW_VERSION" >> $GITHUB_ENV
32-
if [ "v$RAW_VERSION" != "${{ github.ref_name }}" ]; then
33-
echo "Error: Git tag (${{ github.ref_name }}) does not match hatch version (v$RAW_VERSION)"
35+
if [ "v$RAW_VERSION" != "$REF_NAME" ]; then
36+
echo "Error: Git tag ($REF_NAME) does not match hatch version (v$RAW_VERSION)"
3437
exit 1
3538
fi
3639
@@ -52,7 +55,7 @@ jobs:
5255
env:
5356
VERSION: ${{ env.VERSION }}
5457
run: |
55-
if curl -s -f "https://hub.docker.com/v2/repositories/socketdev/cli/tags/${{ env.VERSION }}" > /dev/null; then
58+
if curl -s -f "https://hub.docker.com/v2/repositories/socketdev/cli/tags/${VERSION}" > /dev/null; then
5659
echo "Docker image socketdev/cli:${VERSION} already exists"
5760
echo "docker_exists=true" >> $GITHUB_OUTPUT
5861
else
@@ -113,4 +116,4 @@ jobs:
113116
socketdev/cli:latest
114117
socketdev/cli:${{ env.VERSION }}
115118
build-args: |
116-
CLI_VERSION=${{ env.VERSION }}
119+
CLI_VERSION=${{ env.VERSION }}

.github/workflows/version-check.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ on:
77
- 'setup.py'
88
- 'pyproject.toml'
99

10+
permissions:
11+
contents: read
12+
pull-requests: write
13+
issues: write
14+
1015
jobs:
1116
check_version:
1217
runs-on: ubuntu-latest
1318
steps:
1419
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
1520
with:
1621
fetch-depth: 0 # Fetch all history for all branches
22+
persist-credentials: false
1723

1824
- name: Check version increment
1925
id: version_check

.github/zizmor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rules:
2+
secrets-outside-env:
3+
disable: true

0 commit comments

Comments
 (0)