From 9f977d263d0c4b2eaf6e4d0214ba944e49177c8c Mon Sep 17 00:00:00 2001 From: Toni de la Fuente Date: Wed, 7 Feb 2018 22:47:13 -0500 Subject: [PATCH 1/3] Fixed mktemp in OSX --- prowler | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/prowler b/prowler index 527d90d2..02e0e3e9 100755 --- a/prowler +++ b/prowler @@ -168,6 +168,7 @@ SCRIPT_START_TIME=$( date -u +"%Y-%m-%dT%H:%M:%S%z" ) # Functions to manage dates depending on OS if [ "$OSTYPE" == "linux-gnu" ] || [ "$OSTYPE" == "linux-musl" ]; then + TEMP_REPORT_FILE=$(mktemp -t -p /tmp prowler.cred_report-XXXXXX) # function to compare in days, usage how_older_from_today date # date format %Y-%m-%d how_older_from_today() @@ -193,6 +194,7 @@ if [ "$OSTYPE" == "linux-gnu" ] || [ "$OSTYPE" == "linux-musl" ]; then } elif [[ "$OSTYPE" == "darwin"* ]]; then # BSD/OSX commands compatibility + TEMP_REPORT_FILE=$(mktemp -t prowler.cred_report-XXXXXX) how_older_from_today() { DATE_TO_COMPARE=$1 @@ -570,7 +572,6 @@ genCredReport() { # Save report to a file, decode it, deletion at finish and after every single check saveReport(){ - TEMP_REPORT_FILE=$(mktemp -t -p /tmp prowler-${ACCOUNT_NUM}.cred_report-XXXXXX) $AWSCLI iam get-credential-report --query 'Content' --output text $PROFILE_OPT --region $REGION | decode_report > $TEMP_REPORT_FILE if [[ $KEEPCREDREPORT -eq 1 ]]; then textTitle "0.2" "Saving IAM Credential Report ..." "NOT_SCORED" "SUPPORT" @@ -581,6 +582,7 @@ saveReport(){ # Delete temporary report file cleanTemp(){ if [[ $KEEPCREDREPORT -ne 1 ]]; then + cd /tmp rm -fr $TEMP_REPORT_FILE fi } From c447e456d0cd6930377a8f690ac6ddf09b64bb18 Mon Sep 17 00:00:00 2001 From: Toni de la Fuente Date: Wed, 7 Feb 2018 22:48:02 -0500 Subject: [PATCH 2/3] Fixed mktemp in OSX --- prowler | 1 - 1 file changed, 1 deletion(-) diff --git a/prowler b/prowler index 02e0e3e9..1008b775 100755 --- a/prowler +++ b/prowler @@ -582,7 +582,6 @@ saveReport(){ # Delete temporary report file cleanTemp(){ if [[ $KEEPCREDREPORT -ne 1 ]]; then - cd /tmp rm -fr $TEMP_REPORT_FILE fi } From b92ba781ba3f4bb8dbb10a8a43bcdf625f27f922 Mon Sep 17 00:00:00 2001 From: Toni de la Fuente Date: Wed, 7 Feb 2018 22:52:32 -0500 Subject: [PATCH 3/3] Fixed mktemp in OSX and OS handlign --- prowler | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/prowler b/prowler index 1008b775..49a3ba9f 100755 --- a/prowler +++ b/prowler @@ -216,6 +216,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then } elif [[ "$OSTYPE" == "cygwin" ]]; then # POSIX compatibility layer and Linux environment emulation for Windows + TEMP_REPORT_FILE=$(mktemp -t -p /tmp prowler.cred_report-XXXXXX) how_older_from_today() { DATE_TO_COMPARE=$1 @@ -236,7 +237,8 @@ elif [[ "$OSTYPE" == "cygwin" ]]; then base64 -d } else - echo "Unknown Operating System" + echo "Unknown Operating System! Valid \$OSTYPE: linux-gnu, linux-musl, darwin* or cygwin" + echo "Found: $OSTYPE" EXITCODE=1 exit $EXITCODE fi