Skip to content

Commit

Permalink
fix(extra764): NoSuchBucket error properly handled. (#1094)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCloudSec authored Mar 31, 2022
1 parent 5de2bf7 commit 734331d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions checks/check_extra764
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ extra764(){
TEMP_STP_POLICY_FILE=$(mktemp -t prowler-${ACCOUNT_NUM}-${bucket}.policy.XXXXXXXXXX)
BUCKET_LOCATION=$(${AWSCLI} s3api get-bucket-location ${PROFILE_OPT} --region ${REGION} --bucket ${bucket} --output text 2>&1)
if grep -q -E 'AccessDenied|UnauthorizedOperation|AuthorizationError' <<< "${BUCKET_LOCATION}"; then
textInfo "Access Denied Trying to Get Bucket Location for ${bucket}"
textInfo "Access Denied Trying to Get Bucket Location for ${bucket}" "${REGION}" "${bucket}"
continue
elif grep -E 'NoSuchBucket' <<< "${BUCKET_LOCATION}"; then
textInfo "NoSuchBucket error Bucket ${bucket} does not exist" "${REGION}" "${bucket}"
continue
fi
if [[ "${BUCKET_LOCATION}" == "None" ]]; then
Expand All @@ -44,7 +47,7 @@ extra764(){
# get bucket policy
TEMP_STP_POLICY_FILE=$(${AWSCLI} s3api get-bucket-policy ${PROFILE_OPT} --bucket ${bucket} --output text --query Policy --region ${BUCKET_LOCATION} 2>&1)
if grep -q -E 'AccessDenied|UnauthorizedOperation|AuthorizationError' <<< "${TEMP_STP_POLICY_FILE}"; then
textInfo "Access Denied Trying to Get Bucket Policy for ${bucket}"
textInfo "Access Denied Trying to Get Bucket Policy for ${bucket}" "${REGION}" "${bucket}"
rm -f "${TEMP_STP_POLICY_FILE}"
continue
fi
Expand All @@ -65,7 +68,7 @@ extra764(){
textFail "Bucket ${bucket} allows requests over insecure transport" "${BUCKET_LOCATION}" "${bucket}"
fi
else
textInfo "Unknown Error occurred: ${TEMP_STP_POLICY_FILE}"
textInfo "Bucket ${bucket} returned an unknown error" "${REGION}" "${bucket}"
fi
rm -fr "${TEMP_STP_POLICY_FILE}"
done
Expand Down

0 comments on commit 734331d

Please sign in to comment.