ci: add snyk for image scan (#3031)

This commit is contained in:
Jonathan Ho
2023-05-11 15:12:20 +00:00
committed by GitHub
parent c675b450c1
commit 169e11771d
+36 -20
View File
@@ -3,16 +3,16 @@ name: Rest proxy
on:
push:
branches:
- "main"
- 'main'
paths:
- ".github/workflows/rest-proxy.yml"
- "proxies/rest/**"
- '.github/workflows/rest-proxy.yml'
- 'proxies/rest/**'
pull_request:
paths:
- ".github/workflows/rest-proxy.yml"
- "proxies/rest/**"
- '.github/workflows/rest-proxy.yml'
- 'proxies/rest/**'
schedule:
- cron: "0 0 * * *"
- cron: '0 0 * * *'
jobs:
build:
@@ -59,6 +59,7 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download artifact
@@ -71,27 +72,42 @@ jobs:
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: "discordeno/rest-proxy:latest"
format: "table"
exit-code: "0"
image-ref: 'discordeno/rest-proxy:latest'
format: 'table'
exit-code: '0'
ignore-unfixed: true
vuln-type: "os,library"
severity: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL"
vuln-type: 'os,library'
severity: 'UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL'
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
if: ${{ github.event_name == 'schedule' }}
with:
image-ref: "discordeno/rest-proxy:latest"
exit-code: "0"
vuln-type: "os,library"
severity: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL"
format: "sarif"
output: "trivy-results.sarif"
image-ref: 'discordeno/rest-proxy:latest'
exit-code: '0'
vuln-type: 'os,library'
severity: 'UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: ${{ github.event_name == 'schedule' }}
with:
sarif_file: "trivy-results.sarif"
sarif_file: 'trivy-results.sarif'
- name: Run Snyk to check Docker image for vulnerabilities
if: ${{ github.event_name == 'schedule' }}
continue-on-error: true
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: 'discordeno/rest-proxy:latest'
args: --file=proxies/rest/Dockerfile
- name: Upload result to GitHub Code Scanning
if: ${{ github.event_name == 'schedule' }}
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: snyk.sarif
build-all-arch:
name: Build image for all architectures
@@ -117,7 +133,7 @@ jobs:
with:
context: proxies/rest
push: false
tags: "discordeno/rest-proxy:latest"
tags: 'discordeno/rest-proxy:latest'
# linux/s390x stuck at yarn install, remove it for now
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le
target: runner
@@ -157,7 +173,7 @@ jobs:
with:
context: proxies/rest
push: true
tags: "ghcr.io/discordeno/rest-proxy:latest"
tags: 'ghcr.io/discordeno/rest-proxy:latest'
# linux/s390x stuck at yarn install, remove it for now
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le
target: runner