Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New check 7150 ELB deletion protection enabled @ManuelUgarte #869

Merged
merged 3 commits into from
Oct 4, 2021

Conversation

ManuelUgarte
Copy link

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This Pull request is called [extra7150] to Check if ELB has deletion protection attribute is enabled.

Comment on lines 32 to 33
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this inside the for-loop might take a lot of time, do we have a workaround to do a for-loop but with the data already obtained?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean for the data already obtained via describe-load-balancers? The attributes do not show there unfortunately. For line 32, since there are multiple versions of ELBv2 (NLB, ALB and Gateway LB) the response/output varies depending on which one it is. The response/output is a list of attributes but the order of those varies in the response depending on the type of ELB and therefore I can't extract the boolean directly. That is why I decided to use grep there to determine the boolean expression. The line 33 is just to make it easier to read for the user instead of returning the full Arn but also because the describe-load-balancer-attributes needs the full arn and can't use only the name of the ELB to run.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, it took a second or so to show data from my 3 deployed ELBs in us-east-1. Please let me know if you have an idea of a workaround I could use.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I did notice I can remove -B 1 from grep -B 1 "deletion_protection.enabled" so I will make that update too before the next update. I didnt say it before but thank you for the feedback!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay!
Thank you for your answer! It looks good to me :)

textInfo "$regx: No ELBs found" "$regx"
fi
done
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EOL

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@toniblyx toniblyx changed the title New Prowler Check 7150 by Manuel Ugarte submitted for review New check 7150 ELB deletion protection enabled @ManuelUgarte Sep 23, 2021
@toniblyx toniblyx changed the base branch from master to 2.5.1 September 23, 2021 08:03
Copy link
Contributor

@w0rmr1d3r w0rmr1d3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@toniblyx toniblyx merged commit 13d8c94 into prowler-cloud:2.5.1 Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants