From 472afa5a1f7cde8eb2ff92b0895c9b532687af0a Mon Sep 17 00:00:00 2001 From: Michael Dickinson <45626543+michael-dickinson-sainsburys@users.noreply.github.com> Date: Thu, 23 Dec 2021 14:27:11 +0000 Subject: [PATCH] New check 7169 Global accelerators are protected by AWS Shield Advanced --- checks/check_extra7169 | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 checks/check_extra7169 diff --git a/checks/check_extra7169 b/checks/check_extra7169 new file mode 100644 index 0000000000..728244ac6d --- /dev/null +++ b/checks/check_extra7169 @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Prowler - the handy cloud security tool (copyright 2019) by Toni de la Fuente +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. + +CHECK_ID_extra7169="7.169" +CHECK_TITLE_extra7169="[extra7169] Check if global accelerators are protected by AWS Shield" +CHECK_SCORED_extra7169="NOT_SCORED" +CHECK_CIS_LEVEL_extra7169="EXTRA" +CHECK_SEVERITY_check="Medium" +CHECK_ASFF_RESOURCE_TYPE_extra7169="AwsGlobalAccelerator" +CHECK_ALTERNATE_extra7169="extra7169" +CHECK_SERVICENAME_extra7169="shield" +CHECK_RISK_extra7169='AWS Shield Advanced provides expanded DDoS attack protection for your resources' +CHECK_REMEDIATION_extra7169='Add as a protected resource in AWS Shield Advanced.' +CHECK_DOC_extra7169='https://docs.aws.amazon.com/waf/latest/developerguide/configure-new-protection.html' +CHECK_CAF_EPIC_extra7169='Infrastructure security' + +extra7169() { + if [[ "$($AWSCLI shield get-subscription-state --output text)" == "ACTIVE" ]]; then + LIST_OF_GLOBAL_ACCELERATORS=$($AWSCLI globalaccelerator list-accelerators --region us-west-2 $PROFILE_OPT --query 'Accelerators[?Enabled].[Name,AcceleratorArn]' --output text) + if [[ $LIST_OF_GLOBAL_ACCELERATORS ]]; then + while read -r accelerator; do + ACCELERATOR_NAME=$(echo $accelerator | awk '{ print $1; }') + ACCELERATOR_ARN=$(echo $accelerator | awk '{ print $2; }') + if aws shield describe-protection --resource-arn $ACCELERATOR_ARN >/dev/null 2>&1; then + textPass "$REGION: Global Accelerator $ACCELERATOR_NAME is protected by AWS Shield Advanced" "$REGION" "$ACCELERATOR_NAME" + else + textFail "$REGION: Global Accelerator $ACCELERATOR_NAME is not protected by AWS Shield Advanced" "$REGION" "$ACCELERATOR_NAME" + fi + done <<<"$LIST_OF_GLOBAL_ACCELERATORS" + else + textPass "$REGION: no global accelerators found" "$REGION" + fi + else + textInfo "No AWS Shield Advanced subscription found. Skipping check." + fi +}