Add feature : SNS bp check
This commit is contained in:
parent
8585fd0e64
commit
17d1147855
@ -1,17 +1,45 @@
|
||||
from models import RuleCheckResult
|
||||
import boto3
|
||||
|
||||
|
||||
# client = boto3.client("")
|
||||
client = boto3.client("sns")
|
||||
|
||||
|
||||
def sns_encrypted_kms():
|
||||
compliant_resources = []
|
||||
non_compliant_resources = []
|
||||
topics = client.list_topics()["Topics"]
|
||||
|
||||
for topic in topics:
|
||||
topic = client.get_topic_attributes(TopicArn=topic["TopicArn"])["Attributes"]
|
||||
if "KmsMasterKeyId" in topic:
|
||||
compliant_resources.append(topic["TopicArn"])
|
||||
else:
|
||||
non_compliant_resources.append(topic["TopicArn"])
|
||||
|
||||
return RuleCheckResult(
|
||||
passed=False, compliant_resources=[], non_compliant_resources=[]
|
||||
passed=not non_compliant_resources,
|
||||
compliant_resources=compliant_resources,
|
||||
non_compliant_resources=non_compliant_resources,
|
||||
)
|
||||
|
||||
|
||||
def sns_topic_message_delivery_notification_enabled():
|
||||
compliant_resources = []
|
||||
non_compliant_resources = []
|
||||
topics = client.list_topics()["Topics"]
|
||||
|
||||
for topic in topics:
|
||||
topic = client.get_topic_attributes(TopicArn=topic["TopicArn"])["Attributes"]
|
||||
|
||||
for key in topic.keys():
|
||||
if key.endswith("FeedbackRoleArn") == True:
|
||||
compliant_resources.append(topic["TopicArn"])
|
||||
break
|
||||
else:
|
||||
non_compliant_resources.append(topic["TopicArn"])
|
||||
|
||||
return RuleCheckResult(
|
||||
passed=False, compliant_resources=[], non_compliant_resources=[]
|
||||
passed=not non_compliant_resources,
|
||||
compliant_resources=compliant_resources,
|
||||
non_compliant_resources=non_compliant_resources,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user