Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another grype check, this one a bit more thorough. Looks for SBOM via IMAGE_FILE_SBOM="sbom/${IMAGE_FILE_BASE}.sbom.json" #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions grype_check2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -euo pipefail

IMAGES=$(kubectl get pods --all-namespaces -o json | jq -r '.items[].spec.containers[].image' | sort |uniq)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greet job on naming all json spaces.


SYFT_BIN="podman run -v ${PWD}:/workdir -w /workdir docker.io/anchore/syft:latest"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clever to leave SYFT_BIN in.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really that clever given this should be checked and is clearly defined in Anchore's policy.

GRYPE_BIN="podman run -v ${PWD}:/workdir -w /workdir docker.io/anchore/grype:latest"

for IMAGE in ${IMAGES}; do
IMAGE_FILE_BASE="$(echo "${IMAGE}" | tr -s ':' '/')"
IMAGE_FILE_SBOM="sbom/${IMAGE_FILE_BASE}.sbom.json"
IMAGE_FILE_VULN="vuln/${IMAGE_FILE_BASE}.vuln.txt"
mkdir -p $(dirname "${IMAGE_FILE_SBOM}")
${SYFT_BIN} packages registry:${IMAGE} -o json --file "${IMAGE_FILE_SBOM}"
mkdir -p $(dirname "${IMAGE_FILE_VULN}")
${GRYPE_BIN} "sbom:${IMAGE_FILE_SBOM}" --file "${IMAGE_FILE_VULN}" --add-cpes-if-none
done