Skip to content

Commit ff12d23

Browse files
committed
Add weekly Snyk Docker image scan to Github actions
1 parent c2048a8 commit ff12d23

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Snyk scheduled Docker base image scan
2+
3+
on:
4+
schedule:
5+
- cron: '0 3 * * 1'
6+
workflow_dispatch:
7+
8+
env:
9+
DOCKER_IMAGE: radarbase/radar-backend
10+
11+
jobs:
12+
security:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Run Snyk to check for vulnerabilities
19+
uses: snyk/actions/docker@master
20+
env:
21+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
22+
with:
23+
image: ${{ env.DOCKER_IMAGE }}
24+
args: >-
25+
--file=Dockerfile
26+
--fail-on=upgradable
27+
--severity-threshold=high
28+
--policy-path=.snyk
29+
--exclude-app-vulns
30+
--org=radar-base
31+
--sarif-file-output=snyk.sarif
32+
33+
# Detected vulnerabilities will appear on Github in Security->Code_scanning_alerts tab
34+
- name: Upload Fitbit result to GitHub Code Scanning
35+
uses: github/codeql-action/upload-sarif@v3
36+
with:
37+
sarif_file: snyk.sarif
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Snyk scheduled code base scan
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * 1'
6+
workflow_dispatch:
7+
8+
jobs:
9+
security:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-node
15+
with:
16+
node-version: 16
17+
cache: npm
18+
19+
- name: Run Snyk to check for vulnerabilities
20+
uses: snyk/actions/gradle-jdk17@master
21+
continue-on-error: true # To make sure that SARIF upload gets called
22+
env:
23+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
24+
with:
25+
args: >-
26+
--all-projects
27+
--configuration-matching='^runtimeClasspath$'
28+
--fail-on=upgradable
29+
--severity-threshold=high
30+
--policy-path=.snyk
31+
--org=radar-base
32+
--sarif-file-output=snyk.sarif
33+
34+
# Detected vulnerabilities will appear on Github in Security->Code_scanning_alerts tab
35+
- name: Upload result to GitHub Code Scanning
36+
uses: github/codeql-action/upload-sarif@v3
37+
with:
38+
sarif_file: snyk.sarif

.github/workflows/snyk.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Snyk test on PR commits
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- dev
8+
- release-*
9+
10+
jobs:
11+
security:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Run Snyk to check for vulnerabilities
17+
uses: snyk/actions/gradle-jdk17@master
18+
env:
19+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
20+
with:
21+
args: >-
22+
--all-projects
23+
--configuration-matching="^runtimeClasspath$"
24+
--severity-threshold=high
25+
--fail-on=upgradable
26+
--org=radar-base
27+
--policy-path=.snyk

.snyk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
2+
version: v1.25.0
3+
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
4+
ignore:
5+
patch: {}

0 commit comments

Comments
 (0)