From 41c6131d10e4fc324c1a18b76f167d389c42a252 Mon Sep 17 00:00:00 2001 From: kbgoll05 <93741485+kbgoll05@users.noreply.github.com> Date: Fri, 5 Nov 2021 15:50:54 -0500 Subject: [PATCH] Add files via upload --- checks/check_extra7158 | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 checks/check_extra7158 diff --git a/checks/check_extra7158 b/checks/check_extra7158 new file mode 100644 index 00000000..2ab4a885 --- /dev/null +++ b/checks/check_extra7158 @@ -0,0 +1,43 @@ +#!/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_extra7158="7.158" +CHECK_TITLE_extra7158="[extra7158] Check if ELBV2 has listeners underneath" +CHECK_SCORED_extra7158="NOT_SCORED" +CHECK_TYPE_extra7158="EXTRA" +CHECK_SEVERITY_extra7158="Medium" +CHECK_ASFF_RESOURCE_TYPE_extra7158="AwsElbv2LoadBalancer" +CHECK_ALTERNATE_check7158="extra7158" +CHECK_SERVICENAME_extra7158="elb" +CHECK_RISK_extra7158='The rules that are defined for a listener determine how the load balancer routes requests to its registered targets.' +CHECK_REMEDIATION_extra7158='Add listeners to Elastic Load Balancers V2.' +CHECK_DOC_extra7158='https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-listener-config.html' +CHECK_CAF_EPIC_extra7158='Data Protection' + +extra7158(){ + for regx in $REGIONS; do + LIST_OF_ELBSV2=$($AWSCLI elbv2 describe-load-balancers --query 'LoadBalancers[*].LoadBalancerArn' $PROFILE_OPT --region $regx --output text) + if [[ $LIST_OF_ELBSV2 ]]; then + for elb in $LIST_OF_ELBSV2; do + LIST_OF_LISTENERS=$($AWSCLI elbv2 describe-listeners $PROFILE_OPT --region $regx --load-balancer-arn $elb --query 'Listeners[*]' --output text) + ELBV2_NAME=$(echo $elb|cut -d\/ -f3) + if [[ $LIST_OF_LISTENERS ]]; then + textPass "$regx: $ELBV2_NAME has listeners underneath" "$regx" "$elb" + else + textFail "$regx: $ELBV2_NAME has no listeners underneath" "$regx" "$elb" + fi + done + else + textInfo "$regx: No ELBs found" "$regx" + fi + done +} \ No newline at end of file