You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Find and scan dependent Docker images for security vulnerabilities
231
231
## Options:
232
-
## * [saveOutput] optional. Save the output to a text file. Example: saveOutput=true
232
+
## * [saveOutput] optional. Save the output to a xml file. Example: saveOutput=true
233
233
.PHONY: image-scan
234
234
image-scan:
235
+
235
236
@rm -f helm_image.list dep-image-scan.txt
236
-
@$(if$(saveOutput), > dep-image-scan.txt)
237
237
@echo "=====Scan dependent Docker images in charts/values.yaml" $(if $(saveOutput), | tee -a dep-image-scan.txt,)
238
-
set -e;\
239
-
scanned_images_tracker_file="$$(mktemp)";\
240
-
scan_image() { \
241
-
img="$$1";\
242
-
src_file="$$2";\
243
-
if [ -z"$$img" ];then \
244
-
echo"Warning: Empty image name provided from $$src_file. Skipping."$(if$(saveOutput), | tee -a dep-image-scan.txt,);\
245
-
return;\
246
-
fi;\
247
-
if grep -Fxq "$$img""$$scanned_images_tracker_file";then \
248
-
echo"= $$img (from $$src_file) - Already Processed"$(if$(saveOutput), | tee -a dep-image-scan.txt,);\
249
-
return;\
250
-
fi;\
251
-
echo"= Scanning $$img (from $$src_file)"$(if$(saveOutput), | tee -a dep-image-scan.txt,);\
252
-
if! docker pull "$$img";then \
253
-
echo"Error: Failed to pull Docker image $$img. Skipping scan."$(if$(saveOutput), | tee -a dep-image-scan.txt,);\
254
-
echo"$$img">>"$$scanned_images_tracker_file";\
255
-
return;\
256
-
fi;\
257
-
echo"$$img">>"$$scanned_images_tracker_file";\
258
-
printf"%s,""$${img}">> helm_image.list ;\
259
-
grype_json_output=$$(docker run --rm -v /var/run/docker.sock:/var/run/docker.sock anchore/grype:latest --output json "$$img" 2>/dev/null);\
260
-
if [ -z"$$grype_json_output" ];then \
261
-
echo"Warning: Grype produced no output for $$img. Command might have failed or image not found/supported by grype."$(if$(saveOutput), | tee -a dep-image-scan.txt,);\
262
-
echo$(if$(saveOutput), | tee -a dep-image-scan.txt,);\
(echo "Package\tVersion\tCVE\tSeverity";echo"$$scan_out_body") | column -t -s $$'\t'$(if$(saveOutput), | tee -a dep-image-scan.txt,);\
279
-
else\
280
-
echo"No vulnerability details to display for $$img (though summary reported counts)."$(if$(saveOutput), | tee -a dep-image-scan.txt,);\
281
-
fi;\
282
-
fi;\
283
-
echo$(if$(saveOutput), | tee -a dep-image-scan.txt,);\
284
-
};\
285
-
util_image=$$(grep -A2 'utilContainer:' charts/values.yaml | grep 'image:' | sed 's/.*image:[[:space:]]*//g' | sed 's/"//g' | xargs);\
286
-
scan_image "$$util_image""charts/values.yaml";\
287
-
haproxy_image=$$(grep -A 3 '^haproxy:' charts/values.yaml | grep -A 1 '^\s*image:' | grep '^\s*repository:' | sed 's/.*repository:[[:space:]]*//g' | sed 's/"//g' | sed 's/#.*//g' | xargs);\
288
-
haproxy_tag=$$(grep -A 4 '^haproxy:' charts/values.yaml | grep -A 2 '^\s*image:' | grep '^\s*tag:' | sed 's/.*tag:[[:space:]]*//g' | sed 's/"//g' | sed 's/{{.*}}/latest/' | sed 's/#.*//g' | xargs);\
0 commit comments