Skip to content

Commit c4910e0

Browse files
authored
Revert "RHOAIENG-16076: tests(gha): pre-pull trivy vulnerabilities db to prevent failures to download later (red-hat-data-services#777)" (red-hat-data-services#1329)
This reverts commit 6477ed4
1 parent f2ea720 commit c4910e0

File tree

1 file changed

+34
-62
lines changed

1 file changed

+34
-62
lines changed

.github/workflows/build-notebooks-TEMPLATE.yaml

Lines changed: 34 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ jobs:
4444
# GitHub image registry used for storing $(CONTAINER_ENGINE)'s cache
4545
CACHE: "ghcr.io/${{ github.repository }}/workbench-images/build-cache"
4646
TRIVY_VERSION: 0.64.1
47-
TRIVY_VULNDB: "/home/runner/.local/share/containers/trivy_db"
4847
# Targets (and their folder) that should be scanned using FS instead of IMAGE scan due to resource constraints
4948
TRIVY_SCAN_FS_JSON: '{}'
5049
# Makefile variables
@@ -247,64 +246,6 @@ jobs:
247246
248247
# endregion
249248

250-
# region Trivy init & DB pre-pull
251-
252-
- name: "pull_request|schedule: resolve target if Trivy scan should run"
253-
id: resolve-target
254-
if: ${{ fromJson(inputs.github).event_name == 'pull_request' || fromJson(inputs.github).event_name == 'schedule' }}
255-
env:
256-
EVENT_NAME: ${{ fromJson(inputs.github).event_name }}
257-
HAS_TRIVY_LABEL: ${{ contains(fromJson(inputs.github).event.pull_request.labels.*.name, 'trivy-scan') }}
258-
FS_SCAN_FOLDER: ${{ fromJson(env.TRIVY_SCAN_FS_JSON)[inputs.target] }}
259-
run: |
260-
if [[ "$EVENT_NAME" == "pull_request" && "$HAS_TRIVY_LABEL" == "true" ]]; then
261-
if [[ -n "$FS_SCAN_FOLDER" ]]; then
262-
TARGET="$FS_SCAN_FOLDER"
263-
TYPE="fs"
264-
else
265-
TARGET="${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
266-
TYPE="image"
267-
fi
268-
elif [[ "$EVENT_NAME" == "schedule" ]]; then
269-
if [[ -n "$FS_SCAN_FOLDER" ]]; then
270-
TARGET="$FS_SCAN_FOLDER"
271-
TYPE="fs"
272-
else
273-
TARGET="${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
274-
TYPE="image"
275-
fi
276-
fi
277-
278-
if [[ -n "$TARGET" ]]; then
279-
echo "target=$TARGET" >> $GITHUB_OUTPUT
280-
echo "type=$TYPE" >> $GITHUB_OUTPUT
281-
echo "Trivy scan will run on $TARGET ($TYPE)"
282-
else
283-
echo "Trivy scan won't run"
284-
fi
285-
286-
# only one db can be downloaded in one call https://github.com/aquasecurity/trivy/issues/3616
287-
- name: Pre-pull Trivy vulnerabilities DB
288-
if: ${{ steps.resolve-target.outputs.target }}
289-
run: |
290-
mkdir ${TRIVY_VULNDB}
291-
podman run --rm \
292-
--env PODMAN_SOCK \
293-
-v ${TRIVY_VULNDB}:/cache \
294-
docker.io/aquasec/trivy:$TRIVY_VERSION \
295-
--cache-dir /cache \
296-
image \
297-
--download-db-only
298-
podman run --rm \
299-
--env PODMAN_SOCK \
300-
-v ${TRIVY_VULNDB}:/cache \
301-
docker.io/aquasec/trivy:$TRIVY_VERSION \
302-
--cache-dir /cache \
303-
image \
304-
--download-java-db-only
305-
306-
# endregion
307-
308249
# region Image build
309250

310251
- name: Compute extra podman build args
@@ -560,6 +501,40 @@ jobs:
560501

561502
# region Trivy vulnerability scan
562503

504+
- name: "pull_request|schedule: resolve target if Trivy scan should run"
505+
id: resolve-target
506+
if: ${{ fromJson(inputs.github).event_name == 'pull_request' || fromJson(inputs.github).event_name == 'schedule' }}
507+
env:
508+
EVENT_NAME: ${{ fromJson(inputs.github).event_name }}
509+
HAS_TRIVY_LABEL: ${{ contains(fromJson(inputs.github).event.pull_request.labels.*.name, 'trivy-scan') }}
510+
FS_SCAN_FOLDER: ${{ fromJson(env.TRIVY_SCAN_FS_JSON)[inputs.target] }}
511+
run: |
512+
if [[ "$EVENT_NAME" == "pull_request" && "$HAS_TRIVY_LABEL" == "true" ]]; then
513+
if [[ -n "$FS_SCAN_FOLDER" ]]; then
514+
TARGET="$FS_SCAN_FOLDER"
515+
TYPE="fs"
516+
else
517+
TARGET="${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
518+
TYPE="image"
519+
fi
520+
elif [[ "$EVENT_NAME" == "schedule" ]]; then
521+
if [[ -n "$FS_SCAN_FOLDER" ]]; then
522+
TARGET="$FS_SCAN_FOLDER"
523+
TYPE="fs"
524+
else
525+
TARGET="${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
526+
TYPE="image"
527+
fi
528+
fi
529+
530+
if [[ -n "$TARGET" ]]; then
531+
echo "target=$TARGET" >> $GITHUB_OUTPUT
532+
echo "type=$TYPE" >> $GITHUB_OUTPUT
533+
echo "Trivy scan will run on $TARGET ($TYPE)"
534+
else
535+
echo "Trivy scan won't run"
536+
fi
537+
563538
- name: Run Trivy vulnerability scanner
564539
if: ${{ steps.resolve-target.outputs.target }}
565540
run: |
@@ -588,12 +563,9 @@ jobs:
588563
podman run --rm \
589564
$PODMAN_ARGS \
590565
-v ${REPORT_FOLDER}:/report \
591-
-v ${TRIVY_VULNDB}:/cache \
592566
docker.io/aquasec/trivy:$TRIVY_VERSION \
593-
--cache-dir /cache \
594567
$SCAN_TYPE \
595568
$SCAN_ARGS \
596-
--skip-db-update \
597569
--scanners vuln --ignore-unfixed \
598570
--exit-code 0 --timeout 30m \
599571
--format template --template "@/report/$REPORT_TEMPLATE" -o /report/$REPORT_FILE \

0 commit comments

Comments
 (0)