Skip to content

Commit 11726aa

Browse files
authored
Merge pull request #1667 from GSA/new-snyk
new snyk
2 parents c450238 + 48ee3d5 commit 11726aa

File tree

3 files changed

+67
-10
lines changed

3 files changed

+67
-10
lines changed

.github/workflows/snyk.yml

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
---
2-
name: Check for Snyk Vulnerabilities
2+
name: Snyk Security
33

44
on:
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

913
jobs:
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
@@ -77,3 +84,41 @@ jobs:
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

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

ckan/Dockerfile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10
1+
FROM python:3.10-slim
22

33
# Install Dependencies
44
# - Download Saxon jar for FGDC2ISO transform (geodatagov)
@@ -10,6 +10,17 @@ RUN apt-get update -y && \
1010
openssl libssl-dev libffi-dev pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl \
1111
vim zip libgeos-dev proj-bin cron default-jre xmlsec1
1212

13+
# Add more to slim image
14+
RUN apt-get install -y git libpq-dev gcc libmagic1 libmagic-dev
15+
16+
# Update PAM packages to fix CVE-2025-6020 SNYK-DEBIAN12-PAM-10378969
17+
RUN apt-get install -y --only-upgrade libpam-modules libpam0g libpam-runtime
18+
19+
# increase security by removing unnecessary packages
20+
RUN apt-get upgrade -y && \
21+
apt-get clean && \
22+
rm -rf /var/lib/apt/lists/*
23+
1324
ARG saxon_ver=9.9.1-7
1425
ADD \
1526
https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/${saxon_ver}/Saxon-HE-${saxon_ver}.jar \

0 commit comments

Comments
 (0)