Skip to content

[DPE-2707] Create trivy scanner #8

[DPE-2707] Create trivy scanner

[DPE-2707] Create trivy scanner #8

Workflow file for this run

name: trivy
on:
push:
branches:
- main
pull_request:
jobs:
build:
uses: ./.github/workflows/build.yaml
scan:
name: Trivy scan
needs: build
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Docker
run: |
sudo snap install docker
sudo addgroup --system docker; sudo adduser $USER docker
newgrp docker
sudo snap disable docker; sudo snap enable docker
- name: Install skopeo
run: |
sudo snap install --devmode --channel edge skopeo
- name: Install yq
run: |
sudo snap install yq
- uses: actions/download-artifact@v3
with:
name: charmed-kafka
- name: Import locally
run: |
version=$(yq '(.version|split("-"))[0]' rockcraft.yaml)
base=$(yq '(.base|split("@"))[1]' rockcraft.yaml)
risk=edge
tag=${version}-${base}-${risk}
sudo skopeo --insecure-policy copy \
oci-archive:charmed-kafka_${tag}_amd64.rock \
docker-daemon:$USER/charmed-kafka:test
docker image ls
- name: Run Trivy vulnerability scanner
run: |
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
aquasec/trivy:latest -b sarif -h trivy-results.sarif image $USER/charmed-kafka:test
# uses: aquasecurity/trivy-action@master
# with:
# image-ref: '$USER/charmed-kafka:test'
# format: 'sarif'
# output: 'trivy-results.sarif'
# severity: 'HIGH,CRITICAL'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'