Skip to content

Commit e1528b7

Browse files
committed
Add weekly Snyk Docker image scan to Github actions
1 parent ccab7f2 commit e1528b7

File tree

5 files changed

+90
-65
lines changed

5 files changed

+90
-65
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Check
3939
run: ./gradlew check
4040

41-
- uses: actions/upload-artifact@v3
41+
- uses: actions/upload-artifact@v4
4242
if: always()
4343
with:
4444
name: integration-test-logs
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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-output-restructure
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+
continue-on-error: true # To make sure that SARIF upload gets called
20+
uses: snyk/actions/docker@master
21+
env:
22+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
23+
with:
24+
image: ${{ env.DOCKER_IMAGE }}
25+
# 'exclude-app-vulns' only tests vulnerabilities in the base image.
26+
# Code base vulnerabilities are tested the scheduled-snyk.yaml action.
27+
args: >-
28+
--file=Dockerfile
29+
--fail-on=upgradable
30+
--severity-threshold=high
31+
--policy-path=.snyk
32+
--exclude-app-vulns
33+
--org=radar-base
34+
--sarif-file-output=snyk.sarif
35+
36+
# Detected vulnerabilities will appear on Github in Security->Code_scanning_alerts tab
37+
- name: Upload result to GitHub Code Scanning
38+
uses: github/codeql-action/upload-sarif@v3
39+
with:
40+
sarif_file: snyk.sarif
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
15+
- name: Run Snyk to check for vulnerabilities
16+
uses: snyk/actions/gradle-jdk17@master
17+
continue-on-error: true # To make sure that SARIF upload gets called
18+
env:
19+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
20+
with:
21+
args: >-
22+
--all-projects
23+
--configuration-matching='^runtimeClasspath$'
24+
--fail-on=upgradable
25+
--severity-threshold=high
26+
--policy-path=.snyk
27+
--org=radar-base
28+
--sarif-file-output=snyk.sarif
29+
30+
# Detected vulnerabilities will appear on Github in Security->Code_scanning_alerts tab
31+
- name: Upload result to GitHub Code Scanning
32+
uses: github/codeql-action/upload-sarif@v3
33+
with:
34+
sarif_file: snyk.sarif

.github/workflows/scheduled_snyk.yaml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/snyk.yaml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
name: Snyk test
1+
name: Snyk test on PR commits
2+
23
on:
34
pull_request:
45
branches:
@@ -8,28 +9,23 @@ on:
89
jobs:
910
security:
1011
runs-on: ubuntu-latest
12+
1113
steps:
1214
- uses: actions/checkout@v3
13-
- uses: snyk/actions/setup@master
14-
with:
15-
snyk-version: v1.1032.0
16-
17-
- uses: actions/setup-java@v3
15+
- uses: actions/setup-node@v3
1816
with:
19-
distribution: temurin
20-
java-version: 17
21-
22-
- name: Setup Gradle
23-
uses: gradle/gradle-build-action@v2
17+
node-version: 16
18+
cache: npm
2419

2520
- name: Run Snyk to check for vulnerabilities
21+
uses: snyk/actions/gradle-jdk17@master
2622
env:
2723
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
28-
run: >
29-
snyk test
30-
--configuration-matching='^runtimeClasspath$'
31-
--org=radar-base
32-
--policy-path=$PWD/.snyk
33-
--all-projects
34-
--severity-threshold=high
35-
--fail-on=upgradable
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

0 commit comments

Comments
 (0)