chore(deps): update dependency aquasecurity/trivy to v0.76.2 #22

Open
Renovate wants to merge 2 commits from renovate/aquasecurity-trivy-0.x into main
pull from: renovate/aquasecurity-trivy-0.x
3 changed files with 71 additions and 21 deletions
Showing only changes of commit c10bad408b - Show all commits

No files matched your search

+41 -17
View File
@@ -7,7 +7,8 @@ inputs:
required: true required: true
target-image: target-image:
description: Target baseline container image reference (e.g. host/server/gitea:latest) description: Target baseline container image reference (e.g. host/server/gitea:latest)
required: true required: false
default: ''
target-branch: target-branch:
description: Target branch name for delta heading (e.g. main) description: Target branch name for delta heading (e.g. main)
required: false required: false
@@ -165,6 +166,14 @@ runs:
echo "ℹ️ Strategy: Direct Trivy image scanning enabled (default). Inspects full container rootfs and package databases for maximum fidelity." echo "ℹ️ Strategy: Direct Trivy image scanning enabled (default). Inspects full container rootfs and package databases for maximum fidelity."
fi fi
target_available=true
if [ -z "${{ inputs.target-image }}" ] || [ "${{ inputs.target-image }}" = "none" ] || [ "${{ inputs.target-image }}" = "null" ]; then
target_available=false
elif ! docker manifest inspect "${{ inputs.target-image }}" >/dev/null 2>&1; then
echo "::warning::Target baseline image '${{ inputs.target-image }}' not found in registry (MANIFEST_UNKNOWN or inaccessible). Falling back to standalone head scan."
target_available=false
fi
for platform in "${PLATFORMS[@]}"; do for platform in "${PLATFORMS[@]}"; do
arch_tag=$(echo "$platform" | sed -e 's#^[a-zA-Z0-9_-]*/##' -e 's#/#-#g') arch_tag=$(echo "$platform" | sed -e 's#^[a-zA-Z0-9_-]*/##' -e 's#/#-#g')
@@ -186,6 +195,7 @@ runs:
fi fi
# Target image extraction & fallback # Target image extraction & fallback
if [ "$target_available" = "true" ]; then
if [ "$use_inbuild" = "true" ]; then if [ "$use_inbuild" = "true" ]; then
echo "Attempting extraction of built-in SBOM for target image ($platform)..." echo "Attempting extraction of built-in SBOM for target image ($platform)..."
docker buildx imagetools inspect "${{ inputs.target-image }}" \ docker buildx imagetools inspect "${{ inputs.target-image }}" \
@@ -201,6 +211,7 @@ runs:
fi fi
cleanup_file "sboms/target/sbom-${arch_tag}.spdx.json" cleanup_file "sboms/target/sbom-${arch_tag}.spdx.json"
fi fi
fi
done done
# Fallbacks if no platform-specific SBOMs were extracted (e.g. single-arch image without index) # Fallbacks if no platform-specific SBOMs were extracted (e.g. single-arch image without index)
@@ -221,7 +232,7 @@ runs:
fi fi
fi fi
if [ -z "$(find sboms/target -type f -name 'sbom-*.spdx.json' 2>/dev/null)" ]; then if [ "$target_available" = "true" ] && [ -z "$(find sboms/target -type f -name 'sbom-*.spdx.json' 2>/dev/null)" ]; then
if [ "$use_inbuild" = "true" ]; then if [ "$use_inbuild" = "true" ]; then
docker buildx imagetools inspect "${{ inputs.target-image }}" \ docker buildx imagetools inspect "${{ inputs.target-image }}" \
--format '{{ json .SBOM.SPDX }}' > sboms/target/sbom-default.spdx.json 2>/dev/null || true --format '{{ json .SBOM.SPDX }}' > sboms/target/sbom-default.spdx.json 2>/dev/null || true
@@ -246,7 +257,7 @@ runs:
head_sbom_err="No SBOM generated and head image could not be inspected" head_sbom_err="No SBOM generated and head image could not be inspected"
fi fi
if [ ${#target_files[@]} -eq 0 ] && [ -z "$target_sbom_err" ]; then if [ "$target_available" = "true" ] && [ ${#target_files[@]} -eq 0 ] && [ -z "$target_sbom_err" ]; then
target_sbom_err="No SBOM generated and target baseline image could not be inspected" target_sbom_err="No SBOM generated and target baseline image could not be inspected"
fi fi
@@ -264,7 +275,9 @@ runs:
done done
fi fi
if [ -n "$target_sbom_err" ]; then if [ "$target_available" != "true" ]; then
echo "TARGET Baseline Image (${{ inputs.target-image }}): ⚠️ NOT AVAILABLE (Registry manifest missing or target empty)"
elif [ -n "$target_sbom_err" ]; then
echo "TARGET Baseline Image (${{ inputs.target-image }}): ❌ FAILED - $target_sbom_err" echo "TARGET Baseline Image (${{ inputs.target-image }}): ❌ FAILED - $target_sbom_err"
else else
echo "TARGET Baseline Image (${{ inputs.target-image }}): ✅ SUCCESS" echo "TARGET Baseline Image (${{ inputs.target-image }}): ✅ SUCCESS"
@@ -280,7 +293,7 @@ runs:
echo "::error::Head SBOM extraction failed: $head_sbom_err" echo "::error::Head SBOM extraction failed: $head_sbom_err"
has_sbom_err=true has_sbom_err=true
fi fi
if [ -n "$target_sbom_err" ]; then if [ "$target_available" = "true" ] && [ -n "$target_sbom_err" ]; then
echo "::error::Target baseline SBOM extraction failed: $target_sbom_err" echo "::error::Target baseline SBOM extraction failed: $target_sbom_err"
has_sbom_err=true has_sbom_err=true
fi fi
@@ -416,9 +429,18 @@ runs:
fi fi
# 2. Scan Target SBOMs # 2. Scan Target SBOMs
if [ ${#target_sboms[@]} -eq 0 ]; then target_available=true
if [ -z "${{ inputs.target-image }}" ] || [ "${{ inputs.target-image }}" = "none" ] || [ "${{ inputs.target-image }}" = "null" ]; then
target_available=false
fi
if [ "$target_available" = "false" ] || [ ${#target_sboms[@]} -eq 0 ]; then
if [ "$target_available" = "true" ]; then
target_ok=false target_ok=false
target_summary+=(" - ❌ No SBOM files found in sboms/target/") target_summary+=(" - ⚠️ No baseline SBOM files found (target image manifest unavailable)")
else
target_summary+=(" - ℹ️ Target baseline not specified")
fi
else else
for f in "${target_sboms[@]}"; do for f in "${target_sboms[@]}"; do
arch=$(basename "$f" .spdx.json | sed 's/sbom-//') arch=$(basename "$f" .spdx.json | sed 's/sbom-//')
@@ -512,31 +534,33 @@ runs:
echo "================================================================================" echo "================================================================================"
echo "" echo ""
# 4. Enforce Gating: Both must have succeeded with valid reports # 4. Enforce Gating
has_error=false has_error=false
if [ "$head_ok" != "true" ] || [ "$head_report_count" -eq 0 ]; then if [ "$head_ok" != "true" ] || [ "$head_report_count" -eq 0 ]; then
echo "::error::Head image CVE analysis failed or produced no reports." echo "::error::Head image CVE analysis failed or produced no reports."
has_error=true has_error=true
fi fi
if [ "$target_ok" != "true" ] || [ "$target_report_count" -eq 0 ]; then
echo "::error::Target baseline CVE analysis failed or produced no reports."
has_error=true
fi
if [ "$has_error" = "true" ]; then if [ "$has_error" = "true" ]; then
echo "::error::Aborting differential analysis: both head and target scans must succeed before diffing." echo "::error::Aborting analysis: head scan must succeed."
exit 1 exit 1
fi fi
# 5. Run multi-arch set-based diff and generate consolidated full summary report # 5. Run report generation (differential if target available, otherwise standalone summary)
if [ "$target_ok" = "true" ] && [ "$target_report_count" -gt 0 ]; then
echo "Both head and target scans succeeded. Computing set-based vulnerability delta..." echo "Both head and target scans succeeded. Computing set-based vulnerability delta..."
target_path="cve-reports/target"
else
echo "Target baseline report unavailable. Generating standalone full vulnerability report..."
target_path="--none"
fi
if ! node "${{ github.action_path }}/cve-diff.js" \ if ! node "${{ github.action_path }}/cve-diff.js" \
"cve-reports/target" \ "$target_path" \
"cve-reports/head" \ "cve-reports/head" \
"${{ inputs.target-branch }}" \ "${{ inputs.target-branch }}" \
"${{ inputs.output-summary }}" > "${{ inputs.output-delta }}"; then "${{ inputs.output-summary }}" > "${{ inputs.output-delta }}"; then
echo "::error::Failed to generate CVE differential report" echo "::error::Failed to generate CVE report"
exit 1 exit 1
fi fi
+18 -4
View File
@@ -344,16 +344,30 @@ function main() {
const baseName = args[2] || 'main'; const baseName = args[2] || 'main';
const summaryOutputPath = args[3]; const summaryOutputPath = args[3];
const baseCves = loadReportsForArg(baseArg);
const branchCves = loadReportsForArg(branchArg); const branchCves = loadReportsForArg(branchArg);
const output = renderMarkdownDiff(baseCves, branchCves, baseName);
console.log(output);
if (summaryOutputPath) { if (summaryOutputPath) {
const summaryOutput = renderFullSummary(branchCves); const summaryOutput = renderFullSummary(branchCves);
fs.writeFileSync(summaryOutputPath, summaryOutput, 'utf8'); fs.writeFileSync(summaryOutputPath, summaryOutput, 'utf8');
} }
if (baseArg === '--none' || baseArg === 'none' || baseArg === '') {
// No baseline provided: output full summary as diff report
const lines = [
`### 🛡️ Vulnerability Report (\`${baseName}\` baseline unavailable)`,
'',
`> [!NOTE]`,
`> Baseline target image for \`${baseName}\` was not found in the registry. Showing all detected vulnerabilities.`,
'',
];
lines.push(renderFullSummary(branchCves).replace(/^### 🛡️ Security Scan Report\n*/, ''));
console.log(lines.join('\n'));
return;
}
const baseCves = loadReportsForArg(baseArg);
const output = renderMarkdownDiff(baseCves, branchCves, baseName);
console.log(output);
} }
if (require.main === module) { if (require.main === module) {
+12
View File
@@ -109,3 +109,15 @@ test('formatVulnRow properly formats badge, architecture tag, and escape pipes',
const rowWithoutArch = formatVulnRow(vuln, allArchs, false); const rowWithoutArch = formatVulnRow(vuln, allArchs, false);
assert.ok(!rowWithoutArch.includes('`amd64`')); assert.ok(!rowWithoutArch.includes('`amd64`'));
}); });
test('cve-diff CLI handles --none baseline gracefully and prints full summary', () => {
const { execFileSync } = require('node:child_process');
const headDir = path.join(FIXTURES_DIR, 'head');
const scriptPath = path.join(__dirname, '..', 'cve-diff.js');
const stdout = execFileSync('node', [scriptPath, '--none', headDir, 'main'], { encoding: 'utf8' });
assert.ok(stdout.includes('baseline unavailable'));
assert.ok(stdout.includes('Total Vulnerabilities'));
assert.ok(stdout.includes('CVE-2023-0002'));
assert.ok(stdout.includes('CVE-2023-0003'));
});