-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (55 loc) · 1.67 KB
/
scan-container-for-vulnerabilities.yml
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
name: Scan Docker container for vulnerabilities
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
run-snyk:
runs-on: ubuntu-latest
steps:
- name: Check for required secrets
uses: actions/github-script@v4
with:
script: |
const secrets =
{
SNYK_TOKEN: `${{ secrets.SNYK_TOKEN }}`,
};
const missingSecrets = Object.entries(secrets).filter(([ name, value ]) =>
{
if(value.length === 0)
{
core.error(`Secret "${name}" is not set`);
}
else
{
core.info(`✔️ Secret "${name}" is set`);
}
return;
});
if(missingSecrets.length > 0)
{
core.setFailed(`❌ At least one required secret is not set in the repository. \n`);
}
else
{
core.info(`✅ All the required secrets are set`);
}
- name: Checkout repository
uses: actions/checkout@v2
- name: Build Docker Image
run: docker build -t backend .
- name: Run Snyk to check Docker image for vulnerabilities
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: backend
args: --file=Dockerfile
--severity-threshold=critical
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: snyk.sarif