mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 14:55:00 +00:00
handle permission failure on list-subscriptions-by-topic gracefully
This commit is contained in:
15
prowler
15
prowler
@@ -1237,12 +1237,19 @@ check315(){
|
|||||||
ID315="3.15"
|
ID315="3.15"
|
||||||
TITLE315="Ensure appropriate subscribers to each SNS topic (Not Scored)"
|
TITLE315="Ensure appropriate subscribers to each SNS topic (Not Scored)"
|
||||||
textTitle "$ID315" "$TITLE315" "0"
|
textTitle "$ID315" "$TITLE315" "0"
|
||||||
|
CAN_SNS_LIST_SUBS=1
|
||||||
for regx in $REGIONS; do
|
for regx in $REGIONS; do
|
||||||
TOPICS_LIST=$($AWSCLI sns list-topics --profile $PROFILE --region $regx --output text --query 'Topics[*].TopicArn')
|
TOPICS_LIST=$($AWSCLI sns list-topics --profile $PROFILE --region $regx --output text --query 'Topics[*].TopicArn')
|
||||||
if [[ $TOPICS_LIST ]];then
|
if [[ $TOPICS_LIST && $CAN_SNS_LIST_SUBS -eq 1 ]];then
|
||||||
for topic in $TOPICS_LIST; do
|
for topic in $TOPICS_LIST; do
|
||||||
CHECK_TOPIC_LIST=$($AWSCLI sns list-subscriptions-by-topic --topic-arn $topic --profile $PROFILE --region $regx --query 'Subscriptions[*].{Endpoint:Endpoint,Protocol:Protocol}' --output text --max-items $MAXITEMS | grep -v "None")
|
CHECK_TOPIC_LIST=$($AWSCLI sns list-subscriptions-by-topic --topic-arn $topic --profile $PROFILE --region $regx --query 'Subscriptions[*].{Endpoint:Endpoint,Protocol:Protocol}' --output text --max-items $MAXITEMS)
|
||||||
if [[ $CHECK_TOPIC_LIST ]]; then
|
if [[ $? -eq 255 ]]; then
|
||||||
|
# Permission error
|
||||||
|
export CAN_SNS_LIST_SUBS=0
|
||||||
|
textNotice "No permission to list topics"
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
if [[ $(grep -v 'None' $CHECK_TOPIC_LIST) ]]; then
|
||||||
TOPIC_SHORT=$(echo $topic | awk -F: '{ print $7 }')
|
TOPIC_SHORT=$(echo $topic | awk -F: '{ print $7 }')
|
||||||
textNotice "Region $regx with Topic $TOPIC_SHORT:" "$regx"
|
textNotice "Region $regx with Topic $TOPIC_SHORT:" "$regx"
|
||||||
textNotice "- Suscription: $CHECK_TOPIC_LIST" "$regx"
|
textNotice "- Suscription: $CHECK_TOPIC_LIST" "$regx"
|
||||||
@@ -1251,6 +1258,8 @@ check315(){
|
|||||||
textWarn " - Region $regx and Topic $topic" "$regx"
|
textWarn " - Region $regx and Topic $topic" "$regx"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
elif [[ $CAN_SNS_LIST_SUBS -eq 0 ]]; then
|
||||||
|
break
|
||||||
else
|
else
|
||||||
textNotice "Region $regx doesn't have topics" "$regx"
|
textNotice "Region $regx doesn't have topics" "$regx"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user