Skip to content

Instantly share code, notes, and snippets.

@pict3
Last active December 1, 2021 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pict3/c9fdbbb6b38df859079f61f51499f0c4 to your computer and use it in GitHub Desktop.
Save pict3/c9fdbbb6b38df859079f61f51499f0c4 to your computer and use it in GitHub Desktop.
#!/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