-
-
Notifications
You must be signed in to change notification settings - Fork 25
85 lines (74 loc) · 2.58 KB
/
reusable-snyk-scan-image.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
name: Snyk Scan Image
on:
workflow_call:
inputs:
image:
# 'ghcr.io/${{ github.repository }}:${{ github.sha }}'
description: Image to scan
required: true
type: string
continue-on-error:
description: false if you want job to fail when CVEs are found
required: false
type: boolean
default: true
severity:
description: --severity-threshold=<low|medium|high|critical>
required: false
type: string
default: --severity-threshold=high
dockerfile:
description: Dockerfile location, for best results. Set to '' to disable.
required: false
type: string
default: --file=Dockerfile
app-vulns:
description: Scan app dependencies as well. Set to '' to disable.
required: false
type: string
default: --app-vulns
upload-results:
description: Upload scan results to GitHub Security tab
required: false
type: boolean
default: false
secrets:
registry-username:
description: Username for registry
required: true
registry-password:
description: Password for registry
required: true
snyk-token:
description: Snyk API token
required: true
jobs:
build:
name: CVE Image Scan
runs-on: ubuntu-latest
permissions: read-all
steps:
- name: Which image are we scanning?
run: |
echo "Image to scan: ${{ inputs.image }}"
- name: Checkout git repo
uses: actions/checkout@v4
- name: Run Snyk to check Docker image for vulnerabilities
uses: snyk/actions/docker@master
# Snyk can be used to break the build when it detects vulnerabilities.
# In this case we want to upload the issues to GitHub Code Scanning
continue-on-error: true
env:
# In order to use the Snyk Action you will need to have a Snyk API token.
# More details in https://github.com/snyk/actions#getting-your-snyk-token
# or you can signup for free at https://snyk.io/login
SNYK_TOKEN: ${{ secrets.snyk-token }}
with:
image: ${{ inputs.image }}
args: ${{ inputs.severity }} ${{ inputs.dockerfile }} ${{ inputs.app-vulns }} --username=${{ secrets.registry-username }} --password=${{ secrets.registry-password }}
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v3
if: always() && inputs.upload-results
with:
sarif_file: snyk.sarif