Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/image/vulnerability_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,20 @@ func RunVulnerabilityScan(ctx context.Context, imagePath string, settings builda
// GET https://ghcr.io/v2/aquasecurity/trivy-db/manifests/2: TOOMANYREQUESTS: retry-after: 508.904┬Ás, allowed: 44000/minute
//
// FATAL Fatal error init error: DB error: failed to download vulnerability DB: OCI artifact error: failed to download vulnerability DB: failed to download artifact from any source
if i < 10 && strings.Contains(sResult, "failed to download vulnerability DB") {
if strings.Contains(sResult, "failed to download vulnerability DB") {
log.Println("Will retry")
time.Sleep(time.Second)
} else {
return nil, fmt.Errorf("failed to run trivy: %w", err)
}
}

// All retry attempts were exhausted return the underlying Trivy error
// rather than falling through to json.Unmarshal with error output.
if err != nil {
return nil, fmt.Errorf("failed to run trivy: %w", err)
}

var trivyResult TrivyResult
if err := json.Unmarshal(result, &trivyResult); err != nil {
return nil, err
Expand Down