mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 14:55:00 +00:00
fix(copyToS3): Upload to S3 only when indicated (#1134)
Co-authored-by: sergargar <sergio@verica.io>
This commit is contained in:
@@ -13,23 +13,14 @@
|
||||
|
||||
if [[ $OUTPUT_BUCKET ]]; then
|
||||
# output mode has to be set to other than text
|
||||
if [[ "${MODES[@]}" =~ "html" ]] || [[ "${MODES[@]}" =~ "csv" ]] || [[ "${MODES[@]}" =~ "json" ]] || [[ "${MODES[@]}" =~ "json-asff" ]]; then
|
||||
OUTPUT_BUCKET_WITHOUT_FOLDERS=$(echo $OUTPUT_BUCKET | awk -F'/' '{ print $1 }')
|
||||
# OUTPUT_BUCKET_STATUS=$($AWSCLI s3api head-bucket --bucket "$OUTPUT_BUCKET" 2>&1 || true)
|
||||
# if [[ -z $OUTPUT_BUCKET_STATUS ]]; then
|
||||
# echo "$OPTRED ERROR!$OPTNORMAL wrong bucket name or not right permissions."
|
||||
# exit 1
|
||||
# else
|
||||
# need to make sure last / is not set to avoid // in S3
|
||||
if [[ $OUTPUT_BUCKET != *"/" ]]; then
|
||||
OUTPUT_BUCKET="$OUTPUT_BUCKET"
|
||||
else
|
||||
OUTPUT_BUCKET=${OUTPUT_BUCKET::-1}
|
||||
fi
|
||||
# fi
|
||||
else
|
||||
echo "$OPTRED ERROR!$OPTNORMAL - Mode (-M) has to be set as well. Use -h for help."
|
||||
if [[ "${MODES[*]}" =~ "text" ]]; then
|
||||
echo "$OPTRED ERROR!$OPTNORMAL - Mode (-M) can't be text when using custom output bucket. Use -h for help."
|
||||
exit 1
|
||||
else
|
||||
# need to make sure last / is not set to avoid // in S3
|
||||
if [[ $OUTPUT_BUCKET == *"/" ]]; then
|
||||
OUTPUT_BUCKET=${OUTPUT_BUCKET::-1}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
12
prowler
12
prowler
@@ -694,7 +694,9 @@ if [[ $GROUP_ID_READ ]];then
|
||||
if [[ $OUTPUT_BUCKET_NOASSUME ]]; then
|
||||
restoreInitialAWSCredentials
|
||||
fi
|
||||
copyToS3
|
||||
if [[ $OUTPUT_BUCKET ]]; then
|
||||
copyToS3
|
||||
fi
|
||||
exit $EXITCODE
|
||||
else
|
||||
textFail "Group ${GROUP_ID_READ} does not exist. Use a valid check group ID i.e.: group1, extras, forensics-ready, etc."
|
||||
@@ -725,7 +727,9 @@ if [[ $CHECK_ID ]];then
|
||||
if [[ $OUTPUT_BUCKET_NOASSUME ]]; then
|
||||
restoreInitialAWSCredentials
|
||||
fi
|
||||
copyToS3
|
||||
if [[ $OUTPUT_BUCKET ]]; then
|
||||
copyToS3
|
||||
fi
|
||||
scoring
|
||||
cleanTemp
|
||||
exit $EXITCODE
|
||||
@@ -742,6 +746,8 @@ cleanTemp
|
||||
if [[ $OUTPUT_BUCKET_NOASSUME ]]; then
|
||||
restoreInitialAWSCredentials
|
||||
fi
|
||||
copyToS3
|
||||
if [[ $OUTPUT_BUCKET ]]; then
|
||||
copyToS3
|
||||
fi
|
||||
|
||||
exit $EXITCODE
|
||||
|
||||
Reference in New Issue
Block a user