1+ name : " Serverless Init Vulnerability Scan"
2+
3+ on :
4+ schedule :
5+ # daily at midnight
6+ - cron : " 0 0 * * *"
7+ workflow_dispatch :
8+
9+ env :
10+ # adds public.ecr.aws as fallback incase rate limit on ghcr.io is hit
11+ TRIVY_DB_REPOSITORY : ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
12+ TRIVY_JAVA_DB_REPOSITORY : ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
13+
14+ jobs :
15+ trivy-scans :
16+ runs-on : ubuntu-22.04
17+ steps :
18+ - name : Scan latest serverless-init image with trivy
19+ uses : aquasecurity/trivy-action@dc5a429b52fcf669ce959baa2c2dd26090d2a6c4 # v0.32.0
20+ with :
21+ image-ref : " datadog/serverless-init:latest"
22+ ignore-unfixed : true
23+ exit-code : 1
24+ format : table
25+
26+ - name : Scan latest-alpine serverless-init image with trivy
27+ uses : aquasecurity/trivy-action@dc5a429b52fcf669ce959baa2c2dd26090d2a6c4 # v0.32.0
28+ with :
29+ image-ref : " datadog/serverless-init:latest-alpine"
30+ ignore-unfixed : true
31+ exit-code : 1
32+ format : table
33+
34+ grype-scans :
35+ runs-on : ubuntu-22.04
36+ steps :
37+ - name : Scan latest serverless-init image with grype
38+ uses : anchore/scan-action@16910ac423301c6d30554b83a7f71ac6ff4a51f3 # v6.4.0
39+ with :
40+ image : " datadog/serverless-init:latest"
41+ only-fixed : true
42+ fail-build : true
43+ severity-cutoff : low
44+ output-format : table
45+
46+ - name : Scan latest-alpine serverless-init image with grype
47+ uses : anchore/scan-action@16910ac423301c6d30554b83a7f71ac6ff4a51f3 # v6.4.0
48+ with :
49+ image : " datadog/serverless-init:latest-alpine"
50+ only-fixed : true
51+ fail-build : true
52+ severity-cutoff : low
53+ output-format : table
54+
55+ retry :
56+ needs : [trivy-scans, grype-scans]
57+ if : failure() && fromJSON(github.run_attempt) < 2
58+ runs-on : ubuntu-22.04
59+ permissions :
60+ actions : write
61+ steps :
62+ - name : Retry failed action
63+ env :
64+ GH_REPO : ${{ github.repository }}
65+ GH_TOKEN : ${{ github.token }}
66+ run : gh workflow run retry-workflow.yml -F run_id=${{ github.run_id }}
67+
68+ notify :
69+ needs : [trivy-scans, grype-scans]
70+ if : failure() && fromJSON(github.run_attempt) >= 2
71+ runs-on : ubuntu-22.04
72+ steps :
73+ - name : Notify
74+ env :
75+ SLACK_CHANNEL : " #serverless-agent"
76+ SLACK_WEBHOOK : ${{ secrets.SLACK_WEBHOOK }}
77+ run : |
78+ set -x
79+
80+ OPS_MESSAGE=":gh-check-failed: Serverless Init Vulnerability Scan failed! :radar-scan:
81+
82+ Whoever is on support, please fix the vulnerability, before a customer alerts us to it.
83+
84+ See ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} for the full info on the found vulnerability. :bufo-thanks:"
85+
86+ curl -H "Content-type: application/json" -X POST "$SLACK_WEBHOOK" -d '{
87+ "channel": "'"$SLACK_CHANNEL"'",
88+ "text": "'"$OPS_MESSAGE"'"
89+ }'
0 commit comments