From 4230e9dc1316d829d665fb39c58392e91b2828ed Mon Sep 17 00:00:00 2001 From: Julio Delgado Jr Date: Thu, 30 Apr 2020 20:12:19 -0400 Subject: [PATCH] added elapsed times, support run prower parallel --- .../src/run-prowler-reports.sh | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/util/org-multi-account/src/run-prowler-reports.sh b/util/org-multi-account/src/run-prowler-reports.sh index 9b12b9d2..c8a44216 100644 --- a/util/org-multi-account/src/run-prowler-reports.sh +++ b/util/org-multi-account/src/run-prowler-reports.sh @@ -82,18 +82,30 @@ s3_account_session() { echo "AWS Accounts in Organization" echo "$ACCOUNTS_IN_ORGS" for accountId in $ACCOUNTS_IN_ORGS; do - # Unset AWS Profile Variables - unset_aws - # Run Prowler - Report="prowler-reports/$(date +'%Y-%m-%d-%H%M%P')-$accountId-report.html" - echo -e "Analyzing AWS Account: $accountId, using Role: $ROLE" - ./prowler/prowler -R "$ROLE" -A "$accountId" -g cislevel1 | ansi2html -la >"$Report" - echo "Report stored locally at: $Report" - # Upload Prowler Report to S3 - s3_account_session - aws s3 cp "$Report" "$S3/reports/" - echo "" + # shellcheck disable=SC2015 + test "$(jobs | wc -l)" -ge 1 && wait || true + { + START_TIME=$SECONDS + # Unset AWS Profile Variables + unset_aws + # Run Prowler + Report="prowler-reports/$(date +'%Y-%m-%d-%H%M%P')-$accountId-report.html" + echo -e "Assessing AWS Account: $accountId, using Role: $ROLE on $(date)" + ./prowler/prowler -R "$ROLE" -A "$accountId" -g cislevel1 | ansi2html -la >"$Report" + echo "Report stored locally at: $Report" + # Upload Prowler Report to S3 + s3_account_session + aws s3 cp "$Report" "$S3/reports/" + TOTAL_SEC=$((SECONDS - START_TIME)) + echo -e "Completed AWS Account: $accountId, using Role: $ROLE on $(date)" + printf "Completed AWS Account: $accountId in %02dh:%02dm:%02ds" $((TOTAL_SEC / 3600)) $((TOTAL_SEC % 3600 / 60)) $((TOTAL_SEC % 60)) + echo "" + } & done +# Wait for All Prowler Processes to finish +wait +echo "Prowler Assessments Completed against All Accounts in the AWS Organization" + # Unset AWS Profile Variables unset_aws