refactor!: to use hardened docker environment to run Trivy #55
+15
-18
@@ -4,33 +4,30 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-setup-trivy:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
arch: [ amd64, arm64 ]
|
|
||||||
name: Test Setup Trivy ${{ matrix.arch }}
|
|
||||||
runs-on:
|
|
||||||
- ubuntu-latest
|
|
||||||
- linux_${{ matrix.arch }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
||||||
- name: Setup Trivy
|
|
||||||
uses: ./setup-trivy
|
|
||||||
- name: Run Trivy
|
|
||||||
run: trivy --version
|
|
||||||
|
|
||||||
test-setup-db:
|
test-setup-db:
|
||||||
name: Test Setup DB
|
name: Test Setup DB
|
||||||
runs-on:
|
runs-on:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
- uses: ./setup-trivy
|
|
||||||
- name: Setup DB
|
- name: Setup DB
|
||||||
id: setup-db
|
id: setup-db
|
||||||
uses: ./setup-db
|
uses: ./setup-db
|
||||||
- name: Run Trivy
|
- name: Verify vulnerability DB in cache
|
||||||
run: trivy fs --skip-db-update --cache-dir ${{ steps.setup-db.outputs.cache-dir }} .
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
cache="${{ steps.setup-db.outputs.cache-dir }}"
|
||||||
|
db="$cache/db/trivy.db"
|
||||||
|
meta="$cache/db/metadata.json"
|
||||||
|
test -f "$meta" || { echo "FAIL: $meta missing (DB not downloaded?)"; exit 1; }
|
||||||
|
test -f "$db" || { echo "FAIL: $db missing (DB not downloaded?)"; exit 1; }
|
||||||
|
size=$(stat -c%s "$db")
|
||||||
|
min=$((3 * 1024 * 1024))
|
||||||
|
if [ "$size" -lt "$min" ]; then
|
||||||
|
echo "FAIL: trivy.db too small ($size bytes; expected at least $min bytes, i.e. a few MiB)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "OK: trivy.db is present ($size bytes) and metadata.json exists."
|
||||||
|
|
||||||
test-get-images-from-files:
|
test-get-images-from-files:
|
||||||
name: Test Get Images From Files
|
name: Test Get Images From Files
|
||||||
|
|||||||
Reference in New Issue
Block a user