Skip to content

Commit

Permalink
improve_extra727
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielsoltz committed Oct 24, 2019
1 parent 231f0e6 commit d026ed5
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions checks/check_extra727
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,45 @@ CHECK_TYPE_extra727="EXTRA"
CHECK_ALTERNATE_check727="extra727"

extra727(){
for regx in $REGIONS; do
LIST_SQS=$($AWSCLI sqs list-queues $PROFILE_OPT --region $regx --query QueueUrls --output text |grep -v ^None)
if [[ $LIST_SQS ]]; then
for queue in $LIST_SQS; do
SQS_POLICY=$($AWSCLI sqs get-queue-attributes --queue-url $queue $PROFILE_OPT --region $regx --attribute-names All --query Attributes.Policy --output text)
if [[ "$SQS_POLICY" != "None" ]]; then
SQS_POLICY_ALLOW_ALL=$($AWSCLI sqs get-queue-attributes --queue-url $queue $PROFILE_OPT --region $regx --attribute-names All --query Attributes \
| jq '.Policy | fromjson' | jq '.Statement[] | select(.Effect=="Allow") | select(.Principal=="*" or .Principal.AWS=="*" or .Principal.CanonicalUser=="*")')
if [[ $SQS_POLICY_ALLOW_ALL ]]; then
SQS_POLICY_ALLOW_ALL_WITHOUT_CONDITION=$($AWSCLI sqs get-queue-attributes --queue-url $queue $PROFILE_OPT --region $regx --attribute-names All --query Attributes \
| jq '.Policy | fromjson' | jq '.Statement[] | select(.Effect=="Allow") | select(.Principal=="*" or .Principal.AWS=="*" or .Principal.CanonicalUser=="*") | select(has("Condition") | not)')
if [[ $SQS_POLICY_ALLOW_ALL_WITHOUT_CONDITION ]]; then
SQS_POLICY_ALLOW_ALL_WITHOUT_CONDITION_DETAILS=$($AWSCLI sqs get-queue-attributes --queue-url $queue $PROFILE_OPT --region $regx --attribute-names All --query Attributes \
| jq '.Policy | fromjson' | jq '.Statement[] | select(.Effect=="Allow") | select(.Principal=="*" or .Principal.AWS=="*" or .Principal.CanonicalUser=="*") | select(has("Condition") | not)' | jq '"[Principal: " + (.Principal|tostring) + " Action: " + .Action + "]"' )
textFail "$regx: SQS $queue queue policy with public access: $SQS_POLICY_ALLOW_ALL_WITHOUT_CONDITION_DETAILS" "$regx"
else
textInfo "$regx: SQS $queue queue policy with public access but has a Condition" "$regx"
fi
else
textPass "$regx: SQS $queue queue without public access" "$regx"
fi
else
textPass "$regx: SQS $queue queue without policy" "$regx"
fi
done
else
textInfo "$regx: No SQS queues found" "$regx"
fi
done










for regx in $REGIONS; do
LIST_SQS=$($AWSCLI sqs list-queues $PROFILE_OPT --region $regx --query QueueUrls --output text |grep -v ^None)
if [[ $LIST_SQS ]]; then
Expand Down

0 comments on commit d026ed5

Please sign in to comment.