Skip to content

Commit f514d5a

Browse files
committed
Update scheduled docker image scan action
1 parent 5479a4b commit f514d5a

File tree

1 file changed

+42
-29
lines changed

1 file changed

+42
-29
lines changed

.github/workflows/scheduled-snyk-docker.yaml

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,57 +6,70 @@ on:
66
workflow_dispatch:
77

88
env:
9-
DOCKER_IMAGE_FITBIT: radarbase/kafka-connect-rest-fitbit-source
10-
DOCKER_IMAGE_OURA: radarbase/kafka-connect-rest-oura-source
9+
REGISTRY: ghcr.io
10+
REPOSITORY: ${{ github.repository }}
11+
IMAGES: >-
12+
[{
13+
'name': 'kafka-connect-fitbit-source',
14+
'build_file': 'kafka-connect-fitbit-source/Dockerfile',
15+
'authors': 'Pim van Nierop <[email protected]>, Pauline Conde <[email protected]>',
16+
'description': 'RADAR-base Fitbit connector application'
17+
},{
18+
'name': 'kafka-connect-oura-source',
19+
'build_file': 'kafka-connect-oura-source/Dockerfile',
20+
'authors': 'Pim van Nierop <[email protected]>, Pauline Conde <[email protected]>',
21+
'description': 'RADAR-base Oura connector application'
22+
}]
1123
1224
jobs:
25+
prepare-matrix:
26+
name: Prepare Matrix Output
27+
permissions: {}
28+
runs-on: ubuntu-latest
29+
outputs:
30+
images: ${{ steps.step1.outputs.matrix }}
31+
steps:
32+
- name: Create Matrix Variable
33+
id: step1
34+
run: echo "matrix=${{ env.IMAGES }}" >> $GITHUB_OUTPUT
35+
1336
security:
37+
needs: prepare-matrix
1438
runs-on: ubuntu-latest
39+
strategy:
40+
matrix:
41+
image: ${{ fromJson(needs.prepare-matrix.outputs.images ) }}
42+
permissions:
43+
contents: read
44+
packages: write
1545

1646
steps:
1747
- uses: actions/checkout@v3
1848

19-
- name: Run Snyk to check for vulnerabilities on Fitbit image
49+
- name: Lowercase image name
50+
run: |
51+
echo "DOCKER_IMAGE=${REGISTRY}/${REPOSITORY,,}/${{ matrix.image.name }}" >>${GITHUB_ENV}
52+
53+
- name: Run Snyk to check for vulnerabilities
2054
continue-on-error: true # To make sure that SARIF upload gets called
2155
uses: snyk/actions/docker@master
2256
env:
2357
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
2458
with:
25-
image: ${{ env.DOCKER_IMAGE_FITBIT }}
59+
image: ${{ env.DOCKER_IMAGE }}
2660
args: >-
27-
--file=kafka-connect-fitbit-source/Dockerfile
61+
--file=${{ matrix.image.build_file }}
2862
--fail-on=upgradable
2963
--severity-threshold=high
3064
--policy-path=.snyk
3165
--exclude-app-vulns
3266
--org=radar-base
33-
--sarif-file-output=snyk.sarif
67+
--sarif-file-output=${{ matrix.image.name }}.sarif
3468
3569
# Detected vulnerabilities will appear on Github in Security->Code_scanning_alerts tab
36-
- name: Upload Fitbit result to GitHub Code Scanning
70+
- name: Upload result to GitHub Code Scanning
3771
uses: github/codeql-action/upload-sarif@v3
3872
with:
39-
category: fitbit
4073
sarif_file: snyk.sarif
74+
category: ${{ matrix.image.name }}
4175

42-
- name: Run Snyk to check for vulnerabilities on Oura image
43-
continue-on-error: true # To make sure that SARIF upload gets called
44-
uses: snyk/actions/docker@master
45-
env:
46-
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
47-
with:
48-
image: ${{ env.DOCKER_IMAGE_OURA }}
49-
args: >-
50-
--file=kafka-connect-oura-source/Dockerfile
51-
--fail-on=upgradable
52-
--severity-threshold=high
53-
--policy-path=.snyk
54-
--exclude-app-vulns
55-
--org=radar-base
56-
--sarif-file-output=snyk.sarif
57-
58-
- name: Upload Oura result to GitHub Code Scanning
59-
uses: github/codeql-action/upload-sarif@v3
60-
with:
61-
category: oura
62-
sarif_file: snyk.sarif

0 commit comments

Comments
 (0)