forked from inno-devops-labs/DevOps-Core-Course
-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (59 loc) · 1.72 KB
/
python-snyk.yml
File metadata and controls
61 lines (59 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Python Snyk Scan
on:
push:
paths:
- app_python/**
- .github/actions/python-setup/**
- .github/workflows/python-snyk.yml
pull_request:
branches:
- master
paths:
- app_python/**
- .github/actions/python-setup/**
- .github/workflows/python-snyk.yml
jobs:
snyk:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./app_python
steps:
- uses: actions/checkout@v6
- name: Setup Python tooling and dependencies
uses: ./.github/actions/python-setup
with:
uv-version: 0.11.14
install-args: --locked --no-dev
- name: Setup Snyk CLI
uses: snyk/actions/setup@master
- name: Verify Snyk requirements export
run: |
uv export \
--locked \
--no-dev \
--no-annotate \
--no-header \
--no-hashes \
--format requirements.txt \
--output-file /tmp/snyk-requirements.txt \
> /dev/null
diff -u requirements.txt /tmp/snyk-requirements.txt
- name: Prepare Snyk scan environment
run: |
uv venv --seed .snyk-venv
uv pip install --python .snyk-venv/bin/python -r requirements.txt
- name: Run Snyk dependency scan
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
run: |
if [ -z "${SNYK_TOKEN:-}" ]; then
echo "SNYK_TOKEN secret not set; skipping Snyk dependency scan."
exit 0
fi
snyk test \
--file=requirements.txt \
--package-manager=pip \
--command=.snyk-venv/bin/python \
--severity-threshold=medium \
--fail-on=upgradable