From af4b5539e6697c5adf07c091d5124017491fd349 Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Sun, 28 Nov 2021 13:13:11 +0100 Subject: [PATCH] fix(assumed-role): Check if -T and -A options are set --- include/assume_role | 6 +++--- prowler | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/assume_role b/include/assume_role index 95bd3e0046..ba4778339f 100644 --- a/include/assume_role +++ b/include/assume_role @@ -11,9 +11,9 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -# both variables are mandatory to be set together assume_role(){ - if [[ -z $ROLE_TO_ASSUME ]]; then + # Both variables are mandatory to be set togethe + if [[ -z $ROLE_TO_ASSUME || -z $ACCOUNT_TO_ASSUME ]]; then echo "$OPTRED ERROR!$OPTNORMAL - Both Account ID (-A) and IAM Role to assume (-R) must be set" exit 1 fi @@ -89,4 +89,4 @@ assume_role(){ cleanSTSAssumeFile() { rm -fr "${TEMP_STS_ASSUMED_FILE}" -} \ No newline at end of file +} diff --git a/prowler b/prowler index cae80272eb..0b8a1b2741 100755 --- a/prowler +++ b/prowler @@ -392,7 +392,7 @@ show_group_title() { # Function to execute the check execute_check() { - if [[ $ACCOUNT_TO_ASSUME ]]; then + if [[ -n "${ACCOUNT_TO_ASSUME}" || -n "${ROLE_TO_ASSUME}" ]]; then # Following logic looks for time remaining in the session and review it # if it is less than 600 seconds, 10 minutes. CURRENT_TIMESTAMP=$(date -u "+%s") @@ -639,7 +639,7 @@ fi # Gather account data / test aws cli connectivity getWhoami -if [[ $ACCOUNT_TO_ASSUME ]]; then +if [[ -n "${ACCOUNT_TO_ASSUME}" || -n "${ROLE_TO_ASSUME}" ]]; then assume_role fi