11---
2- name : Check for Snyk Vulnerabilities
2+ name : Snyk Security
33
44on :
55 workflow_dispatch :
66 schedule :
7- - cron : ' 0 12 * * *' # every day at 12pm UTC
7+ # Run weekly on Sundays at 2:00 AM EST (7:00 AM UTC)
8+ - cron : ' 0 7 * * 0'
9+ push :
10+ branches :
11+ - main
812
913jobs :
10- snyk :
14+ snyk-test :
1115 name : snyk test
1216 runs-on : ubuntu-latest
17+ if : github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
1318 steps :
1419 - name : Checkout
1520 uses : actions/checkout@v4
1621 - name : Set up Python 3.10
1722 uses : actions/setup-python@v5
1823 with :
19- python-version : ' 3.10'
24+ python-version : 3.10.14
25+ cache : ' pip'
2026 - name : Display Python version
2127 run : python -c "import sys; print(sys.version)"
2228 - name : Install Dependencies
@@ -28,26 +34,27 @@ jobs:
2834 libxmlsec1-dev libxmlsec1-openssl libgeos-dev proj-bin \
2935 libpq-dev
3036 pip3 install -r requirements.txt
37+ # yamllint disable rule:line-length
3138 - name : Run Snyk Scan
3239 run : |
3340 # Run scan
3441 snyk auth ${{ secrets.SNYK_TOKEN }}
35- snyk test --severity-threshold=medium --file=ckan/ requirements.txt --json-file-output=scan.json || echo "Scan complete"
42+ snyk test --severity-threshold=medium --file=requirements.txt --json-file-output=/tmp/ scan.json || echo "Scan complete"
3643
3744 # Exit if no vulnerabilities
3845 # Succeed, so that PR is NOT created
39- [[ "$(jq '.ok' scan.json)" == "true" ]] && exit 0
46+ [[ "$(jq '.ok' /tmp/ scan.json)" == "true" ]] && exit 0
4047
4148 # Update requirements.in with the snyk fix suggestions
42- python tools /snyk-update.py
49+ python bin /snyk-update.py
4350
4451 # Update requirements.txt
45- make update-dependencies
52+ make requirements
4653
4754 # Check if there are any changes
4855 if [ -z "$(git status --porcelain)" ]; then
4956 echo "Found vulnerable issues but no upgrade or patch available"
50- cat scan.json | jq '[.vulnerabilities[] | .id] | unique[]'
57+ cat /tmp/ scan.json | jq '[.vulnerabilities[] | .id] | unique[]'
5158 else
5259 echo "Changes made to add into PR: "
5360 git diff
7784 automated pr
7885 snyk
7986 draft : false
87+ # yamllint enable rule:line-length
88+
89+ snyk-monitor :
90+ name : snyk monitor
91+ permissions :
92+ contents : read
93+ runs-on : ubuntu-latest
94+ if : github.event_name == 'push'
95+ steps :
96+ - name : Checkout
97+ uses : actions/checkout@v4
98+
99+ - name : Set up Python 3.10
100+ uses : actions/setup-python@v5
101+ with :
102+ python-version : 3.10.14
103+ cache : ' pip'
104+
105+ - name : Display Python version
106+ run : python -c "import sys; print(sys.version)"
107+
108+ - name : Install Dependencies
109+ run : |
110+ npm install snyk -g
111+ sudo apt-get update -y
112+ sudo apt-get install -y \
113+ openssl libssl-dev libffi-dev pkg-config libxml2-dev \
114+ libxmlsec1-dev libxmlsec1-openssl libgeos-dev proj-bin \
115+ libpq-dev
116+ pip3 install -r requirements.txt
117+
118+ - name : Run Snyk Monitor
119+ run : |
120+ # Authenticate with Snyk
121+ snyk auth ${{ secrets.SNYK_TOKEN }}
122+
123+ # Run snyk monitor to track dependencies
124+ snyk monitor --file=requirements.txt
0 commit comments