Complete Lab 7 security and PKI track
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$repo = Split-Path -Parent $PSScriptRoot
|
||||
$trivy = Get-Command trivy -ErrorAction SilentlyContinue
|
||||
if (-not $trivy) { throw 'Install Trivy and ensure it is on PATH before running this scan.' }
|
||||
Push-Location $repo
|
||||
try {
|
||||
docker compose build api db bao-renew openbao redis s3 lb grafana
|
||||
$images = @(
|
||||
'mtusi-messenger-lab7-api:local',
|
||||
'mtusi-messenger-lab7-bao-renew:local',
|
||||
'mtusi-messenger-lab7-openbao:local',
|
||||
'mtusi-messenger-lab7-postgres:local',
|
||||
'mtusi-messenger-lab7-redis:local',
|
||||
'mtusi-messenger-lab7-rustfs:local',
|
||||
'mtusi-messenger-lab7-nginx:local',
|
||||
'otel/opentelemetry-collector-contrib:0.166.0',
|
||||
'prom/prometheus:v3.16.0',
|
||||
'grafana/loki:3.6.23',
|
||||
'grafana/tempo:2.10.10',
|
||||
'mtusi-messenger-lab7-grafana:local'
|
||||
)
|
||||
New-Item -ItemType Directory -Force evidence | Out-Null
|
||||
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
|
||||
foreach ($image in $images) {
|
||||
$safe = $image -replace '[^A-Za-z0-9._-]', '_'
|
||||
$output = Join-Path 'evidence' "trivy-$stamp-$safe.json"
|
||||
& $trivy.Source image --scanners vuln --severity HIGH,CRITICAL --ignorefile .trivyignore.yaml --show-suppressed --format json --output $output $image
|
||||
if ($LASTEXITCODE -ne 0) { throw "Trivy could not scan image $image" }
|
||||
Write-Host "Saved scan: $output"
|
||||
}
|
||||
$fsOutput = Join-Path 'evidence' "trivy-$stamp-filesystem.json"
|
||||
# Dockerfile.example is an intentionally non-runnable teaching outline.
|
||||
& $trivy.Source fs --scanners vuln,misconfig,secret --skip-dirs .git,.venv,secrets --skip-files Dockerfile.example --format json --output $fsOutput .
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Trivy could not scan the repository filesystem.' }
|
||||
Write-Host "Saved scan: $fsOutput"
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
Reference in New Issue
Block a user