Skip to content

Commit c682284

Browse files
committed
feat(templates): add security job (Bandit + Safety) to scaffolded CI workflow
1 parent be762fc commit c682284

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

python_project_deployment/templates/ci.yaml.j2

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,48 @@ jobs:
8282
run: |
8383
uv pip install twine
8484
twine check dist/*
85+
86+
security:
87+
name: Security Scan (Bandit + Safety)
88+
runs-on: ubuntu-latest
89+
needs: test
90+
permissions:
91+
contents: read
92+
security-events: write
93+
94+
steps:
95+
- uses: actions/checkout@v4
96+
97+
- name: Install uv
98+
run: |
99+
curl -LsSf https://astral.sh/uv/install.sh | sh
100+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
101+
102+
- name: Create virtual environment
103+
run: uv venv
104+
105+
- name: Install security tools
106+
run: |
107+
source .venv/bin/activate
108+
uv pip install bandit safety
109+
110+
- name: Run Bandit (security linter)
111+
run: |
112+
source .venv/bin/activate
113+
bandit -r {{ PKG }} -f json -o bandit-report.json || true
114+
bandit -r {{ PKG }} -f txt
115+
116+
- name: Run Safety (dependency vulnerability scanner)
117+
run: |
118+
source .venv/bin/activate
119+
safety check --json > safety-report.json || true
120+
safety check
121+
122+
- name: Upload security reports
123+
if: always()
124+
uses: actions/upload-artifact@v4
125+
with:
126+
name: security-reports
127+
path: |
128+
bandit-report.json
129+
safety-report.json

0 commit comments

Comments
 (0)