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 "$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