added elapsed times, support run prower parallel

This commit is contained in:
Julio Delgado Jr
2020-04-30 20:12:19 -04:00
parent 36e9f5174d
commit 4230e9dc13

View File

@@ -82,18 +82,30 @@ s3_account_session() {
echo "AWS Accounts in Organization" echo "AWS Accounts in Organization"
echo "$ACCOUNTS_IN_ORGS" echo "$ACCOUNTS_IN_ORGS"
for accountId in $ACCOUNTS_IN_ORGS; do for accountId in $ACCOUNTS_IN_ORGS; do
# Unset AWS Profile Variables # shellcheck disable=SC2015
unset_aws test "$(jobs | wc -l)" -ge 1 && wait || true
# Run Prowler {
Report="prowler-reports/$(date +'%Y-%m-%d-%H%M%P')-$accountId-report.html" START_TIME=$SECONDS
echo -e "Analyzing AWS Account: $accountId, using Role: $ROLE" # Unset AWS Profile Variables
./prowler/prowler -R "$ROLE" -A "$accountId" -g cislevel1 | ansi2html -la >"$Report" unset_aws
echo "Report stored locally at: $Report" # Run Prowler
# Upload Prowler Report to S3 Report="prowler-reports/$(date +'%Y-%m-%d-%H%M%P')-$accountId-report.html"
s3_account_session echo -e "Assessing AWS Account: $accountId, using Role: $ROLE on $(date)"
aws s3 cp "$Report" "$S3/reports/" ./prowler/prowler -R "$ROLE" -A "$accountId" -g cislevel1 | ansi2html -la >"$Report"
echo "" 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 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 Profile Variables
unset_aws unset_aws