scan release images with trivy #4879
Workflow file for this run
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: "Lint" | |
on: # yamllint disable-line rule:truthy | |
push: | |
branches: | |
- "!dependabot/*" | |
- "main" | |
pull_request: | |
branches: ["*"] | |
merge_group: | |
types: | |
- "checks_requested" | |
env: | |
GO_VERSION: "~1.20.6" | |
jobs: | |
go-lint: | |
name: "Lint Go" | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: "actions/checkout@v3" | |
- uses: "authzed/actions/setup-go@main" | |
with: | |
go-version: "${{ env.GO_VERSION }}" | |
- name: "Lint Go" | |
run: "go run mage.go lint:go" | |
- uses: "chainguard-dev/actions/nodiff@main" | |
with: | |
path: "" | |
fixup-command: "go run mage.go lint:go" | |
extra-lint: | |
name: "Lint YAML & Markdown" | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: "actions/checkout@v3" | |
- name: "Lint Everything Else" | |
run: "go run mage.go lint:extra" | |
- uses: "chainguard-dev/actions/nodiff@main" | |
with: | |
path: "" | |
fixup-command: "go run mage.go lint:extra" | |
codeql: | |
name: "Analyze with CodeQL" | |
runs-on: "ubuntu-latest-8-cores" | |
permissions: | |
actions: "read" | |
contents: "read" | |
security-events: "write" | |
strategy: | |
fail-fast: false | |
matrix: | |
language: ["go"] | |
steps: | |
- uses: "actions/checkout@v3" | |
- uses: "authzed/actions/codeql@main" | |
trivy-fs: | |
name: "Analyze FS with Trivy" | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: "actions/checkout@v3" | |
- uses: "aquasecurity/trivy-action@master" | |
with: | |
scan-type: "fs" | |
ignore-unfixed: true | |
format: 'table' | |
exit-code: '1' | |
severity: "CRITICAL,HIGH,MEDIUM" | |
trivy-image: | |
name: "Analyze Release Image with Trivy" | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: "actions/checkout@v3" | |
- uses: "authzed/actions/setup-go@main" | |
with: | |
go-version: "${{ env.GO_VERSION }}" | |
- name: "modify goreleaser config to skip building all targets" | |
run: | | |
echo "partial: | |
by: target" >> .goreleaser.yml | |
- name: "build image" | |
run: 'DOCKER_BUILDKIT=1 docker build --platform=linux/amd64 -t authzed/spicedb:scanme .' | |
- name: "image metadata" | |
run: 'docker image inspect authzed/spicedb:scanme' | |
- name: "run trivy" | |
run: 'docker run -v /var/run/docker.sock:/var/run/docker.sock aquasec/trivy image -d --platform linux/amd64 --format table --exit-code 0 --ignore-unfixed --vuln-type os,library --no-progress --severity CRITICAL,HIGH,MEDIUM authzed/spicedb:scanme' | |
- name: "install trivy" | |
run: | | |
wget https://github.com/aquasecurity/trivy/releases/download/v0.43.1/trivy_0.43.1_Linux-64bit.deb | |
sudo dpkg -i trivy_0.43.1_Linux-64bit.deb | |
- name: "run trivy" | |
run: 'trivy image -d --platform linux/amd64 --format table --exit-code 0 --ignore-unfixed --vuln-type os,library --no-progress --severity CRITICAL,HIGH,MEDIUM authzed/spicedb:scanme' | |
- uses: "goreleaser/goreleaser-action@v4" | |
id: "goreleaser" | |
with: | |
distribution: "goreleaser-pro" | |
version: "latest" | |
args: "release --clean --split --snapshot" | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
GORELEASER_KEY: "${{ secrets.GORELEASER_KEY }}" | |
- name: "Obtain container image to scan" | |
run: 'echo "IMAGE_VERSION=$(jq .version dist/linux_amd64/metadata.json --raw-output)" >> $GITHUB_ENV' | |
- name: "run trivy manually" | |
run: 'docker run -v /var/run/docker.sock:/var/run/docker.sock aquasec/trivy image --format table --exit-code 1 --ignore-unfixed --vuln-type os,library --no-progress --severity CRITICAL,HIGH,MEDIUM authzed/spicedb:v${{ env.IMAGE_VERSION }}-amd64' |