forked from mtusi2026/mtusi2026lab7
lab 7 done
This commit is contained in:
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user