From 5c6b81dd8b582544a02ac8a859d3b4f2505200c7 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Tue, 14 Sep 2021 19:57:40 +0000 Subject: [PATCH 1/3] elb deletion protection enabled checkextra 7150 --- checks/check_extra7150 | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 checks/check_extra7150 diff --git a/checks/check_extra7150 b/checks/check_extra7150 new file mode 100644 index 00000000..d78a2b78 --- /dev/null +++ b/checks/check_extra7150 @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# Prowler - the handy cloud security tool (copyright 2018) 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_extra7150="7.150" +CHECK_TITLE_extra7150="[extra7150] Check if Elastic Load Balancers have deletion protection enabled" +CHECK_SCORED_extra7150="NOT_SCORED" +CHECK_TYPE_extra7150="EXTRA" +CHECK_SEVERITY_extra7150="Medium" +CHECK_ASFF_RESOURCE_TYPE_extra7150="AwsElbLoadBalancer" +CHECK_ALTERNATE_check7150="extra7150" +CHECK_SERVICENAME_extra7150="elb" +CHECK_RISK_extra7150='If deletion protection is not enabled, the resource is not protected against deletion.' +CHECK_REMEDIATION_extra7150='Enable deletion protection attribute; this is not enabled by default.' +CHECK_DOC_extra7150='https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#deletion-protection' +CHECK_CAF_EPIC_extra7150='Data Protection' + +extra7150(){ + # "Check if Elastic Load Balancers have delete protection enabled." + for regx in $REGIONS; do + LIST_OF_ELBSV2=$($AWSCLI elbv2 describe-load-balancers $PROFILE_OPT --region $regx --query 'LoadBalancers[*].LoadBalancerArn' --output text|xargs -n1) + if [[ $LIST_OF_ELBSV2 ]]; then + for elbarn in $LIST_OF_ELBSV2; do + CHECK_DELETION_PROTECTION_ENABLED=$($AWSCLI elbv2 describe-load-balancer-attributes $PROFILE_OPT --region $regx --load-balancer-arn $elbarn --query Attributes[*] --output text|grep -B 1 "deletion_protection.enabled" | grep true) + ELBV2_NAME=$(echo $elbarn|cut -d\/ -f3) + if [[ $CHECK_DELETION_PROTECTION_ENABLED ]]; then + textPass "$regx: $ELBV2_NAME has the attribute deletion protection enabled" "$regx" "$elb" + else + textFail "$regx: $ELBV2_NAME does not have deletion protection enabled." "$regx" "$elb" + fi + done + else + textInfo "$regx: No ELBs found" "$regx" + fi + done +} \ No newline at end of file From df7a2c6ef3ac990044153d54bd1d8c90a3681740 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Wed, 15 Sep 2021 18:12:11 +0000 Subject: [PATCH 2/3] Added EOL and updated some variables to make it easier to read. --- checks/check_extra7150 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/checks/check_extra7150 b/checks/check_extra7150 index d78a2b78..d2a62d89 100644 --- a/checks/check_extra7150 +++ b/checks/check_extra7150 @@ -28,9 +28,9 @@ extra7150(){ for regx in $REGIONS; do LIST_OF_ELBSV2=$($AWSCLI elbv2 describe-load-balancers $PROFILE_OPT --region $regx --query 'LoadBalancers[*].LoadBalancerArn' --output text|xargs -n1) if [[ $LIST_OF_ELBSV2 ]]; then - for elbarn in $LIST_OF_ELBSV2; do - CHECK_DELETION_PROTECTION_ENABLED=$($AWSCLI elbv2 describe-load-balancer-attributes $PROFILE_OPT --region $regx --load-balancer-arn $elbarn --query Attributes[*] --output text|grep -B 1 "deletion_protection.enabled" | grep true) - ELBV2_NAME=$(echo $elbarn|cut -d\/ -f3) + for elb in $LIST_OF_ELBSV2; do + CHECK_DELETION_PROTECTION_ENABLED=$($AWSCLI elbv2 describe-load-balancer-attributes $PROFILE_OPT --region $regx --load-balancer-arn $elb --query Attributes[*] --output text|grep "deletion_protection.enabled"|grep true ) + ELBV2_NAME=$(echo $elb|cut -d\/ -f3) if [[ $CHECK_DELETION_PROTECTION_ENABLED ]]; then textPass "$regx: $ELBV2_NAME has the attribute deletion protection enabled" "$regx" "$elb" else @@ -41,4 +41,4 @@ extra7150(){ textInfo "$regx: No ELBs found" "$regx" fi done -} \ No newline at end of file +} From 4f7d75598d268c393fdfa145c9d253bfdc043710 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Fri, 1 Oct 2021 15:24:14 +0000 Subject: [PATCH 3/3] Changed ',' with ';' in check variables --- checks/check_extra7150 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checks/check_extra7150 b/checks/check_extra7150 index d2a62d89..26940ad9 100644 --- a/checks/check_extra7150 +++ b/checks/check_extra7150 @@ -18,7 +18,7 @@ CHECK_SEVERITY_extra7150="Medium" CHECK_ASFF_RESOURCE_TYPE_extra7150="AwsElbLoadBalancer" CHECK_ALTERNATE_check7150="extra7150" CHECK_SERVICENAME_extra7150="elb" -CHECK_RISK_extra7150='If deletion protection is not enabled, the resource is not protected against deletion.' +CHECK_RISK_extra7150='If deletion protection is not enabled; the resource is not protected against deletion.' CHECK_REMEDIATION_extra7150='Enable deletion protection attribute; this is not enabled by default.' CHECK_DOC_extra7150='https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#deletion-protection' CHECK_CAF_EPIC_extra7150='Data Protection'