change name of temp file so that it's random

Allows multiple instances of prowler to run in parallel (eg. via xargs
-P ).
Also, add trap handler to remove temp file if interrupted.
This commit is contained in:
Ben Allen
2017-07-07 16:33:42 -05:00
parent 62dfd9a17b
commit 1e3985d3b4

View File

@@ -362,7 +362,7 @@ genCredReport() {
# Save report to a file, decode it, deletion at finish and after every single check, acb stands for AWS CIS Benchmark
saveReport(){
TEMP_REPORT_FILE=/tmp/.acb
TEMP_REPORT_FILE=$(mktemp -t prowler-XXXXX.cred_report )
$AWSCLI iam get-credential-report --query 'Content' --output text --profile $PROFILE --region $REGION | decode_report > $TEMP_REPORT_FILE
}
@@ -371,6 +371,9 @@ cleanTemp(){
rm -fr $TEMP_REPORT_FILE
}
# Delete the temporary report file if we get interrupted/terminated
trap cleanTemp SIGHUP SIGINT SIGTERM
# Get a list of all available AWS Regions
REGIONS=$($AWSCLI ec2 describe-regions --query 'Regions[].RegionName' \
--output text \