3 ################################################################################
4 # Copyright 2023 highstreet technologies GmbH
6 # Licensed under the Apache License, Version 2.0 (the 'License');
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an 'AS IS' BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 ################################################################################
19 # Excluded images is an array containing the name of the docker images we want to exclude from the analysis.
20 # Please modify it according to your needs.
23 # curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
26 # curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
29 if [ -z "$SYFT" ]; then
30 echo "Unable to find syft. Please install."
35 if [ -z "$GRYPE" ]; then
36 echo "Unable to find grype. Please install."
44 image_names=($(docker ps --format '{{.Image}}' | tr ' ' '\n' | sort -u | tr '\n' ' '))
47 for ele in "${excluded_images[@]}"; do
48 image_names=(${image_names[@]/*${ele}*/})
51 echo "Analysing following images: ${image_names[*]}"
53 for image in "${image_names[@]}"; do
54 image_name_no_repo="${image##*/}"
55 echo "Creating SBOM for ${image} in ${image_name_no_repo}.sbom.spdx.json..."
56 ${SYFT} -q ${image} -o spdx-json --file out/${image_name_no_repo}.sbom.spdx.json
57 echo "Creating Vulnerabilities for ${image} in ${image_name_no_repo}.vulnerabilities.vex.json..."
58 ${GRYPE} -q ${image} -o embedded-cyclonedx-vex-json --file out/${image_name_no_repo}.vulnerabilities.vex.json