Last active
December 1, 2021 11:30
-
-
Save pict3/c9fdbbb6b38df859079f61f51499f0c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# @(#) wafcharm-checker4gc.sh ver.1.0.0 2021.12.01 | |
# | |
# Usage: | |
# wafcharm-checker4gc.sh param1 param2 | |
# param1 - policy-name | |
# param2 - sink-name | |
# | |
# Description: | |
# Simple validation for setup status with WafCharm for Google Cloud. | |
# | |
########################################################################### | |
POLICY_NAME=$1 | |
SINK_NAME=$2 | |
echo 'Start validation WafCharm setup status.' | |
ret=$(gcloud compute security-policies describe ${POLICY_NAME} --format json | jq 'map(has("adaptiveProtectionConfig"))' | jq '.[0]') | |
if [[ "$ret" = "false" ]]; then | |
echo "Policy Error!! Check ${POLICY_NAME}'s type is 'Backend security policy'." | |
exit 1 | |
fi | |
ret=$(gcloud logging sinks describe ${SINK_NAME}) | |
if [[ "$?" != 0 ]]; then | |
echo "Sink Error!! Check ${SINK_NAME} is exist." | |
exit 2 | |
fi | |
echo "Easy validation O.K. :)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment