Public Access
generated from Philipp/template-git
Compare commits
5
Commits
57a6d483ee
..
0.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f2be77ba1 | ||
|
|
9e6eef6a37
|
||
|
|
e464443894 | ||
|
|
d92089a5f4
|
||
|
|
6b70a25cf6 |
No files matched your search
+41
-17
@@ -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
|
||||||
|
|
||||||
|
|||||||
+22
-22
@@ -1,22 +1,22 @@
|
|||||||
b8e8834a90b0f28c172498a96d1b91876eb2f09867f02aa314df9a862aa86227 trivy_0.74.0_FreeBSD-64bit.tar.gz
|
89c88a41cc259cb93951a4fc923fbeee145302c369cc098b2af56298569cfa06 trivy_0.75.0_FreeBSD-64bit.tar.gz
|
||||||
cea47f6624cab9123a6bebc2f6586f3f82b8cd3165fc0ecd21677ba8a4ca0f5c trivy_0.74.0_Linux-32bit.deb
|
21e1b4cfadfd4c975ee95c77b03c3ef3ffa8de732cbaf45b729e3bd5a59a4c67 trivy_0.75.0_Linux-32bit.deb
|
||||||
bec3a7aed02d60b6bb2996bb63897f604464c2db0b2b29dfc3cc7ce9959c8aaf trivy_0.74.0_Linux-32bit.rpm
|
b617436b0b55c04f58f1f654ba80e98f1063d21ceaff2cc192f830bacb1d0aba trivy_0.75.0_Linux-32bit.rpm
|
||||||
048af0c9597a8e275f60bb9e0543748dbc76e22bdd52456b84ea0fa0cd2a078a trivy_0.74.0_Linux-32bit.tar.gz
|
5dca0e5b0579a1c5fff1bf7dc541185020a3df892fe7c3345a1bf22988cc0e9c trivy_0.75.0_Linux-32bit.tar.gz
|
||||||
cf1e32ec8d4d8823e023096a28cadb14f5b5123ce03f201fb633c5b76aa712dd trivy_0.74.0_Linux-64bit.deb
|
b6d7b944b6cbf4e7de5b4bc6c3635900c50fed53b64b77b99a5fbc3136cd1d5d trivy_0.75.0_Linux-64bit.deb
|
||||||
2331b82ec0ce5529a09fad8ccbfe03987ec9277ff4fbd6e96c6cb0aff8103477 trivy_0.74.0_Linux-64bit.rpm
|
fba2b73579645839892dfd7b94c5551983f0f094ff88efc94a69383de00a1f26 trivy_0.75.0_Linux-64bit.rpm
|
||||||
2ae6fe3ee734b7fdf11335663e18c75ea12dccc76062f09f164a3b0f8be4371a trivy_0.74.0_Linux-64bit.tar.gz
|
c6e65abddb348e25f10549df887045629cf28cc72453cd1c63acb717316b3f3f trivy_0.75.0_Linux-64bit.tar.gz
|
||||||
5665eaa443bfb117c5c4c373254f0ba9e2888985e6233588ce98bb0960f558c3 trivy_0.74.0_Linux-ARM.deb
|
6d35e18b2f09c3f389c5cf94f0f259c5320debf1ce16c37f010d9a8ca1bec88f trivy_0.75.0_Linux-ARM.deb
|
||||||
bdd73ea298ec538ffae3351614a3adefc8c48599fce7943e6376fcfa040c0e85 trivy_0.74.0_Linux-ARM.rpm
|
a39a931e5b88050892e9811f843e0c05e29c73c03bac4afffc7508a45b215dff trivy_0.75.0_Linux-ARM.rpm
|
||||||
99adbe319fa685cb4bff04dd0077e31cb94828338cab5db7f78fe6dcecca8ec1 trivy_0.74.0_Linux-ARM.tar.gz
|
8cbe2286600ba56267fab0f10cf5696c252993b7b7935c5cef518abab3c84af4 trivy_0.75.0_Linux-ARM.tar.gz
|
||||||
14fae2604eab589fd544224ef56b8b8a44266872c43b259bd36cfde81428acc8 trivy_0.74.0_Linux-ARM64.deb
|
23018f1f7136b8391bb300e2579bcf4759e3c64012856f51c0fb6fffe1ee3841 trivy_0.75.0_Linux-ARM64.deb
|
||||||
bb753f2dacd22417ac7709fdd910a0b017f4bb43330eac8b51c2a90403ae2fd3 trivy_0.74.0_Linux-ARM64.rpm
|
a28a78b82c06049d3b1d8c4b17ddb4586357ccf8e4b0aa1b30d0867beb3b11a0 trivy_0.75.0_Linux-ARM64.rpm
|
||||||
b94ce1976bbf3c15b514b605ee88be7c6d94a29be2302847ff01cb794d47aad5 trivy_0.74.0_Linux-ARM64.tar.gz
|
a1ee9f6ffb7d112b64ff726a2a0717c21175c1114361391f4a132956751a13b3 trivy_0.75.0_Linux-ARM64.tar.gz
|
||||||
16a1e36b6d405951b36f1e4b31bb7655f8551f1581934fcb2e6e5bdf8c46f6c9 trivy_0.74.0_Linux-PPC64LE.deb
|
eed0d48c91904036a1c039c3c8c1c2b13eee8983b101c371dbe49c9ae24d8e01 trivy_0.75.0_Linux-PPC64LE.deb
|
||||||
cc7183af95dbab1ae1400fca17b35ca8f9591676a1042144994698cad9cac5a6 trivy_0.74.0_Linux-PPC64LE.rpm
|
cfefab190d7d972735ed372ec32e5adda6af30ff24d7e0669bfd0eac9a15a1b5 trivy_0.75.0_Linux-PPC64LE.rpm
|
||||||
c5aabfe8789d0d43f578ef2d01174884c8ff0f2106c627a220a43f7bf9054959 trivy_0.74.0_Linux-PPC64LE.tar.gz
|
dbd7403d4191b14efd5ee4a808c93bc97b56fa9f62dd98a691a61bf6e556642e trivy_0.75.0_Linux-PPC64LE.tar.gz
|
||||||
f8fe56cee9a502e82f05e45465943e3bc6e75de05530ffc7bddf93e65b0de5bb trivy_0.74.0_Linux-s390x.deb
|
f440ffa772be9d517f5e03b93bfe99035bc28dd760d841877c5994259481c94a trivy_0.75.0_Linux-s390x.deb
|
||||||
4fb2d5bd1ab5e61917e73cd2936daeae1c5ab9af024321a222437d824bac5579 trivy_0.74.0_Linux-s390x.rpm
|
c1269d4af420a69e81cb0b7cf234728db5bfe6ecc350c78f5f3bbfd0be1c228c trivy_0.75.0_Linux-s390x.rpm
|
||||||
516cfe38eaede79c178088265657aad12be6c155271ac68ff728a141961ef197 trivy_0.74.0_Linux-s390x.tar.gz
|
6acd3a3af4688567f5d3cdf3dd45e871ae060a88c07cea01401ae1487c4f19a3 trivy_0.75.0_Linux-s390x.tar.gz
|
||||||
472816f6888dda689d075c30254d4210b4d1035acf365aa72332f584c2f60485 trivy_0.74.0_macOS-64bit.tar.gz
|
291edaa9778acbe4693d067b5ad60ee11570e5ac68296e85595417528ca641e4 trivy_0.75.0_macOS-64bit.tar.gz
|
||||||
1caada5e0e2091909357c7525d3aa76f4b660b13821bc143b190c7483e31cc11 trivy_0.74.0_macOS-ARM64.tar.gz
|
4a77108cccf8e55c8d6823e1e759939a622277e66cd0daa3c1fc621ed69e4568 trivy_0.75.0_macOS-ARM64.tar.gz
|
||||||
94c40e0696e4b907a74b7b2e1438d5d72ebaca83115817407f568a002d520842 trivy_0.74.0_windows-64bit.zip
|
4e43bd71a30f51aee39525f60f2b47043af77eb8df8fe082aae4372b69c6660f trivy_0.75.0_windows-64bit.zip
|
||||||
+18
-4
@@ -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) {
|
||||||
|
|||||||
@@ -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'));
|
||||||
|
});
|
||||||
Reference in new issue
Block a user