From 7e9a5dc8f51b7df83e6648de632fadfbb1f3c1e3 Mon Sep 17 00:00:00 2001 From: Toni de la Fuente Date: Wed, 16 Sep 2020 23:11:33 +0200 Subject: [PATCH] Allow list checks and groups without credentials --- include/whoami | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/include/whoami b/include/whoami index 4322cb96..f3463d14 100644 --- a/include/whoami +++ b/include/whoami @@ -14,24 +14,24 @@ # Get whoami in AWS, who is the user running this shell script -ACCOUNT_NUM=$($AWSCLI sts get-caller-identity --output text $PROFILE_OPT --region $REGION --query "Account") - -if [[ 255 -eq $? ]]; then - # Failed to get own identity ... exit - echo -e "$RED ERROR Getting credentials to run Prowler - EXITING! $NORMAL" - EXITCODE=2 - exit $EXITCODE -fi - -CALLER_ARN=$($AWSCLI sts get-caller-identity --output text $PROFILE_OPT --region $REGION --query "Arn") -USER_ID=$($AWSCLI sts get-caller-identity --output text $PROFILE_OPT --region $REGION --query "UserId") -AWS_PARTITION=$(echo $CALLER_ARN| cut -d: -f2) - -if [[ $ACCOUNT_TO_ASSUME ]]; then - ACCOUNT_NUM=$ACCOUNT_TO_ASSUME -fi - getWhoami(){ + ACCOUNT_NUM=$($AWSCLI sts get-caller-identity --output text $PROFILE_OPT --region $REGION --query "Account") + + if [[ 255 -eq $? ]]; then + # Failed to get own identity ... exit + echo -e "$RED ERROR Getting credentials to run Prowler - EXITING! $NORMAL" + EXITCODE=2 + exit $EXITCODE + fi + + CALLER_ARN=$($AWSCLI sts get-caller-identity --output text $PROFILE_OPT --region $REGION --query "Arn") + USER_ID=$($AWSCLI sts get-caller-identity --output text $PROFILE_OPT --region $REGION --query "UserId") + AWS_PARTITION=$(echo $CALLER_ARN| cut -d: -f2) + + if [[ $ACCOUNT_TO_ASSUME ]]; then + ACCOUNT_NUM=$ACCOUNT_TO_ASSUME + fi + if [[ "$MODE" == "csv" ]]; then if [[ 255 -eq $? ]]; then # Failed to get own identity ... exit