Skip to content

Instantly share code, notes, and snippets.

@petskratt
Created November 1, 2022 19:29
Show Gist options
  • Save petskratt/0839fe00de386c87aca224d6bbf6a2cf to your computer and use it in GitHub Desktop.
Save petskratt/0839fe00de386c87aca224d6bbf6a2cf to your computer and use it in GitHub Desktop.
Scan images deployed to a K8S cluster for OpenSSL versions
#!/usr/bin/env bash
# [email protected] / 2022-11-01 ("Klytus, I'm bored. What plaything can you offer me today?")
# Scan images deployed to a K8S cluster for OpenSSL versions
#
# prerequisites:
# - kubectl
# - authenticated and authorised to access all namespaces of a cluster
# - Trivy installed https://aquasecurity.github.io/trivy/v0.34/getting-started/installation/
# - Trivy has access to your presumably private registries https://aquasecurity.github.io/trivy/v0.34/docs/advanced/private-registries/gcr/
#
# inspiration:
# - https://blog.aquasec.com/openssl-vulnerability-2022
# - https://kubernetes.io/docs/tasks/access-application-cluster/list-all-running-container-images/
MUCH_IMAGES=$(kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" | tr -s '[[:space:]]' '\n' | sort | uniq)
for SUCH_IMAGE in $MUCH_IMAGES; do
WOW_SSL=$(trivy image -q --format=spdx $SUCH_IMAGE | grep openssl | grep PackageSourceInfo | sort | uniq)
echo -e "$SUCH_IMAGE\t$WOW_SSL"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment