Skip to content

Commit 3853467

Browse files
jfagoagasandoniaf
andauthored
feat(security): improve GHA security (#270)
Co-authored-by: Andoni A. <14891798+andoniaf@users.noreply.github.com>
1 parent 90dfbe6 commit 3853467

File tree

5 files changed

+81
-11
lines changed

5 files changed

+81
-11
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ updates:
1313
labels:
1414
- "dependencies"
1515
- "pip"
16+
cooldown:
17+
default-days: 7
1618
- package-ecosystem: "github-actions"
1719
directory: "/"
1820
schedule:
1921
interval: "monthly"
2022
target-branch: main
23+
cooldown:
24+
default-days: 7

.github/workflows/pull-request.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121

2222
steps:
2323
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
with:
25+
persist-credentials: false
2426

2527
- name: Install poetry
2628
run: |
@@ -68,11 +70,15 @@ jobs:
6870
6971
- name: Safety
7072
run: |
71-
if [ "${{ matrix.python-version }}" = "3.9" ] || [ "${{ matrix.python-version }}" = "3.10" ]; then
72-
poetry run safety check --ignore 82754 --ignore 84183 --ignore 83159
73-
else
74-
poetry run safety check
75-
fi
73+
# 82754: filelock TOCTOU symlink (CVE-2025-68146), fix requires Python >=3.10
74+
# 84183: filelock lock mechanism (PVE-2026-84183), fix requires Python >=3.10
75+
# 83159: marshmallow data conversion (CVE-2025-68480), fix requires Python >=3.10
76+
# 84415: filelock TOCTOU race condition (CVE-2026-22701), fix requires Python >=3.10
77+
poetry run safety check \
78+
--ignore 82754 \
79+
--ignore 84183 \
80+
--ignore 83159 \
81+
--ignore 84415
7682
7783
- name: Vulture
7884
run: |
@@ -85,5 +91,5 @@ jobs:
8591
- name: Upload coverage reports to Codecov
8692
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
8793
with:
88-
token: ${{ secrets.CODECOV_TOKEN }}
94+
token: ${{ secrets.CODECOV_TOKEN }} # zizmor: ignore[secrets-outside-env]
8995
slug: prowler-cloud/py-ocsf-models

.github/workflows/pypi-release.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,23 @@ on:
99
env:
1010
RELEASE_TAG: ${{ github.event.release.tag_name }}
1111
PYTHON_VERSION: 3.11
12-
# CACHE: "poetry"
1312

1413
jobs:
1514
release:
1615
runs-on: ubuntu-latest
16+
environment: release
17+
permissions:
18+
contents: read
19+
id-token: write
1720
env:
1821
POETRY_VIRTUALENVS_CREATE: "false"
1922

2023
name: Release py-ocsf-models to PyPI
2124
steps:
2225

2326
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
27+
with:
28+
persist-credentials: false
2429

2530
- name: Install dependencies
2631
run: |
@@ -30,13 +35,10 @@ jobs:
3035
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
3136
with:
3237
python-version: ${{ env.PYTHON_VERSION }}
33-
# cache: ${{ env.CACHE }}
3438

3539
- name: Build package
3640
run: |
3741
poetry build
3842
3943
- name: Publish package to PyPI
40-
run: |
41-
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
42-
poetry publish
44+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0

.github/workflows/zizmor.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: GitHub Actions Security Analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
paths:
8+
- ".github/workflows/**"
9+
pull_request:
10+
branches:
11+
- "main"
12+
paths:
13+
- ".github/workflows/**"
14+
15+
permissions: {}
16+
17+
jobs:
18+
zizmor-pr:
19+
name: Run zizmor (PR)
20+
if: github.event_name == 'pull_request'
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
actions: read
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
28+
with:
29+
persist-credentials: false
30+
31+
- name: Run zizmor
32+
uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2
33+
with:
34+
advanced-security: "false"
35+
annotations: "true"
36+
37+
zizmor-push:
38+
name: Run zizmor (push)
39+
if: github.event_name == 'push'
40+
runs-on: ubuntu-latest
41+
permissions:
42+
security-events: write
43+
contents: read
44+
actions: read
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
48+
with:
49+
persist-credentials: false
50+
51+
- name: Run zizmor
52+
uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,9 @@ repos:
106106
entry: bash -c 'vulture --exclude "contrib" --min-confidence 100 .'
107107
language: system
108108
files: '.*\.py'
109+
110+
## GITHUB ACTIONS
111+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
112+
rev: v1.23.1
113+
hooks:
114+
- id: zizmor

0 commit comments

Comments
 (0)