DockerVulnerabilities #64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: DockerVulnerabilities | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
# At the end of every day | |
- cron: "0 0 * * *" | |
jobs: | |
docker-analysis: | |
name: Trivy analysis for Docker image | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [amd64, arm64] | |
permissions: | |
contents: read | |
# for sarif | |
security-events: write | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 | |
with: | |
egress-policy: audit | |
allowed-endpoints: > | |
api.github.com:443 | |
auth.docker.io:443 | |
azure.archive.ubuntu.com:80 | |
deb.debian.org:80 | |
esm.ubuntu.com:443 | |
files.pythonhosted.org:443 | |
ghcr.io:443 | |
github.com:443 | |
index.docker.io:443 | |
motd.ubuntu.com:443 | |
packages.microsoft.com:443 | |
pkg-containers.githubusercontent.com:443 | |
production.cloudflare.docker.com:443 | |
pypi.org:443 | |
registry-1.docker.io:443 | |
repo.anaconda.com:443 | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
id: buildx | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-v1.0-validator-node-${{ matrix.arch }}-${{ github.ref_name }} | |
restore-keys: | | |
${{ runner.os }}-buildx-v1.0-validator-node-${{ matrix.arch }} | |
- name: Build and load | |
run: | | |
docker buildx bake \ | |
--set "*.cache-from=type=local,src=/tmp/.buildx-cache" \ | |
--set "*.cache-to=type=local,dest=/tmp/.buildx-cache-new" \ | |
--set "*.platform=linux/${{ matrix.arch }}" \ | |
--builder ${{ steps.buildx.outputs.name }} \ | |
-f docker-compose.yml \ | |
--load \ | |
app worker | |
env: | |
DOCKER_TAG: analysis-latest | |
- name: Scan vulnerabilities app image | |
uses: aquasecurity/trivy-action@7c2007bcb556501da015201bcba5aa14069b74e2 # v0.23.0 | |
with: | |
image-ref: 'pantosio/validator-node-app:analysis-latest' | |
format: 'sarif' | |
output: 'trivy-app-results.sarif' | |
severity: 'CRITICAL,HIGH' | |
- name: Upload Trivy scan results for app to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v3 | |
if: always() | |
with: | |
category: 'validator-node-app-${{ matrix.arch }}' | |
sarif_file: 'trivy-app-results.sarif' | |
- name: Scan vulnerabilities worker image | |
uses: aquasecurity/trivy-action@7c2007bcb556501da015201bcba5aa14069b74e2 # v0.23.0 | |
with: | |
image-ref: 'pantosio/validator-node-worker:analysis-latest' | |
format: 'sarif' | |
output: 'trivy-worker-results.sarif' | |
severity: 'CRITICAL,HIGH' | |
- name: Upload Trivy scan results for worker to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v3 | |
if: always() | |
with: | |
category: 'validator-node-worker-${{ matrix.arch }}' | |
sarif_file: 'trivy-worker-results.sarif' | |
- name: Move cache | |
if: always() | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |