52 lines
1.3 KiB
Bash
52 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
### https://emudhra.we-have-a-problem.com/
|
|
|
|
# set -x
|
|
set -eou pipefail
|
|
|
|
containers=($(docker ps --format {{.Names}}))
|
|
URL="https://dv-g3b-emudhra.we-have-a-problem.com"
|
|
cert_problem=()
|
|
check_problem=()
|
|
|
|
for i in "${containers[@]}"; do
|
|
echo "Checking container $i:"
|
|
|
|
# Checking with curl
|
|
if docker exec $i which curl > /dev/null; then
|
|
if docker exec $i curl --silent $URL > /dev/null; then
|
|
cert_problem+=("${i} (curl)")
|
|
fi
|
|
|
|
# Checking with wget
|
|
elif docker exec $i which wget > /dev/null; then
|
|
if docker exec $i wget --quiet $URL > /dev/null; then
|
|
cert_problem+=("${i} (wget)")
|
|
fi
|
|
|
|
# Checking with OpenSSL
|
|
elif docker exec $i which openssl > /dev/null; then
|
|
result=$(docker exec $i openssl s_client -connect dv-g3b-emudhra.we-have-a-problem.com:443 </dev/null)
|
|
if echo $result | grep -q "Verify return code: 0"; then
|
|
cert_problem+=("${i} (openssl)")
|
|
fi
|
|
else
|
|
check_problem+=($i)
|
|
fi
|
|
echo
|
|
done
|
|
|
|
## Result
|
|
if [[ ${#cert_problem[@]} -eq 0 ]]; then
|
|
echo "All containers are safe!"
|
|
else
|
|
echo "Following containers stil use compromised certificates:"
|
|
printf '%s\n' "${cert_problem[@]}"
|
|
fi
|
|
|
|
if ! [[ ${#check_problem[@]} -eq 0 ]]; then
|
|
echo
|
|
echo "Following containers have no curl, wget or openssl:"
|
|
printf '%s\n' "${check_problem[@]}"
|
|
fi |