Skip to content

Commit 3bb059b

Browse files
authored
fix(ci): fix trivy scan, disable pipeline download (#1673)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Optimized vulnerability scanning to run faster by skipping on-run database updates and pre-downloading the Java vulnerability database. * Improved CI reliability for container image security checks. * **Bug Fixes** * Ensured security scan failures correctly return a non-zero exit code, providing clearer feedback and preventing false positives in pipelines. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent ffd8264 commit 3bb059b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

.github/scripts/generate-sarif-reports.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function generateSarifReport() {
4444
locationsJson="$(yq --arg image "$image" -r '.annotations["artifacthub.io/images"] | split("\n")[] | select(contains($image))' "$chart/Chart.yaml" |
4545
awk '{print $NF}' |
4646
jq -r -c -Rn '[inputs] | map({fullyQualifiedName: .})')"
47-
if trivy image "$image" -f sarif --quiet --ignore-unfixed | jq -r --argjson locations "$locationsJson" --arg category "$chart/${GITHUB_JOB:-local}" '.runs |= map(.results |= map(.locations += [{logicalLocations: $locations}])) | .runs |= map(.automationDetails = {id: $category})' >"$tmpFile"; then
47+
if trivy image --skip-db-update --skip-java-db-update "$image" -f sarif --quiet --ignore-unfixed | jq -r --argjson locations "$locationsJson" --arg category "$chart/${GITHUB_JOB:-local}" '.runs |= map(.results |= map(.locations += [{logicalLocations: $locations}])) | .runs |= map(.automationDetails = {id: $category})' >"$tmpFile"; then
4848
mv "${tmpFile}" "${outFile}"
4949
else
5050
rm "$tmpFile"

.github/scripts/trivy-login-to-registries.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ declare -A IMAGE_PULL_TOKENS=(
1111
)
1212

1313
trivy image --download-db-only
14+
trivy image --download-java-db-only
1415

1516
for registry in "${!IMAGE_PULL_TOKENS[@]}"; do
1617
TRIVY_PASSWORD="${IMAGE_PULL_TOKENS["$registry"]}" trivy registry login --username github-cve-scanning "$registry"

0 commit comments

Comments
 (0)