Skip to content

Serverless Init Vulnerability Scan #110

Serverless Init Vulnerability Scan

Serverless Init Vulnerability Scan #110

name: "Serverless Init Vulnerability Scan"
on:
schedule:
# daily at midnight
- cron: "0 0 * * *"
workflow_dispatch:
env:
# adds public.ecr.aws as fallback incase rate limit on ghcr.io is hit
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
jobs:
trivy-scans:
runs-on: ubuntu-22.04
steps:
- name: Scan latest serverless-init image with trivy
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # v0.33.1
with:
image-ref: "datadog/serverless-init:latest"
ignore-unfixed: true
exit-code: 1
format: table
- name: Scan latest-alpine serverless-init image with trivy
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # v0.33.1
with:
image-ref: "datadog/serverless-init:latest-alpine"
ignore-unfixed: true
exit-code: 1
format: table
grype-scans:
runs-on: ubuntu-22.04
steps:
- name: Scan latest serverless-init image with grype
uses: anchore/scan-action@a5605eb0943e46279cb4fbd9d44297355d3520ab # v7.0.2
with:
image: "datadog/serverless-init:latest"
only-fixed: true
fail-build: true
severity-cutoff: low
output-format: table
- name: Scan latest-alpine serverless-init image with grype
uses: anchore/scan-action@a5605eb0943e46279cb4fbd9d44297355d3520ab # v7.0.2
with:
image: "datadog/serverless-init:latest-alpine"
only-fixed: true
fail-build: true
severity-cutoff: low
output-format: table
retry:
needs: [trivy-scans, grype-scans]
if: failure() && fromJSON(github.run_attempt) < 2
runs-on: ubuntu-22.04
permissions:
actions: write
steps:
- name: Retry failed action
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
run: gh workflow run retry-workflow.yml -F run_id=${{ github.run_id }}
notify:
needs: [trivy-scans, grype-scans]
if: failure() && fromJSON(github.run_attempt) >= 2
runs-on: ubuntu-22.04
steps:
- name: Notify
env:
SLACK_CHANNEL: "#serverless-agent"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
run: |
set -x
OPS_MESSAGE=":gh-check-failed: Serverless Init Vulnerability Scan failed! :radar-scan:
Whoever is on support, please fix the vulnerability, before a customer alerts us to it.
See ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} for the full info on the found vulnerability. :bufo-thanks:"
curl -H "Content-type: application/json" -X POST "$SLACK_WEBHOOK" -d '{
"channel": "'"$SLACK_CHANNEL"'",
"text": "'"$OPS_MESSAGE"'"
}'