#!/bin/sh set -eu cd "$(dirname "$0")/.." work="$PWD/.runtime/scans" mkdir -p "$work/manifests" "$work/cache" cp go.mod go.sum "$work/manifests/" scanner() { docker run --rm --cpus 0.75 --memory 512m \ -v "$work:/scan" aquasec/trivy:0.67.2 --cache-dir /scan/cache \ "$@" } scanner fs --scanners vuln --format json --output /scan/manifests.json /scan/manifests if [ "$#" -eq 0 ]; then # Only images in this project. No Docker socket is mounted into Trivy. set -- $(./scripts/compose.sh --profile operator config --images | sort -u) fi for image do name=$(printf '%s' "$image" | cut -d@ -f1 | tr '/:' '__') printf 'Scanning %s\n' "$image" scan_path="$work/image.tar" docker image save -o "$scan_path" "$image" scanner image --scanners vuln,secret --format json --output "/scan/$name.json" --input /scan/image.tar done