Skip to content

Commit f7e28ca

Browse files
authored
ci: fix snyk security scans in bake_targets.yml (#329)
Closes #327 Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
1 parent 517f68f commit f7e28ca

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.github/workflows/bake.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ jobs:
5151
with:
5252
environment: ${{ github.event.inputs.environment }}
5353
postgresql_version: ${{ matrix.version }}
54+
secrets:
55+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
5456

5557
Catalogs:
5658
name: Update Catalogs

.github/workflows/bake_targets.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ on:
2929
`source` directory.
3030
required: false
3131
type: string
32+
secrets:
33+
SNYK_TOKEN:
34+
required: false
3235

3336
permissions: {}
3437

@@ -158,16 +161,26 @@ jobs:
158161

159162
- name: Snyk
160163
uses: snyk/actions/docker@master
164+
id: snyk
165+
if: ${{ env.SNYK_TOKEN != '' }}
166+
# Snyk can be used to break the build when it detects vulnerabilities.
167+
# In this case we want to upload the issues to GitHub Code Scanning.
161168
continue-on-error: true
162169
env:
163170
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
164171
with:
165172
image: "${{ matrix.image }}"
166173
args: --severity-threshold=high --file=Dockerfile
167174

175+
- name: Replace sarif security-severity invalid values
176+
if: ${{ steps.snyk.conclusion == 'success' }}
177+
run: |
178+
sed -i 's/"security-severity": "null"/"security-severity": "0"/g' snyk.sarif
179+
sed -i 's/"security-severity": "undefined"/"security-severity": "0"/g' snyk.sarif
180+
168181
- name: Upload result to GitHub Code Scanning
169182
uses: github/codeql-action/upload-sarif@192325c86100d080feab897ff886c34abd4c83a3 # v3
170-
continue-on-error: true
183+
if: ${{ steps.snyk.conclusion == 'success' }}
171184
with:
172185
sarif_file: snyk.sarif
173186

0 commit comments

Comments
 (0)