Last active
December 26, 2017 22:12
-
-
Save cowholio4/1841ffae55f747bb3b3837e327632f13 to your computer and use it in GitHub Desktop.
Simple SES Lambda Rule for collecting/filtering spam. https://www.seclytics.com/blog/2017/12/19/amazon-web-services-ses-spam-honeypot/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_spam(event, context): | |
ses_notification = event['Records'][0]['ses'] | |
message_id = ses_notification['mail']['messageId'] | |
receipt = ses_notification['receipt'] | |
print('Processing message:', message_id) | |
is_spam = (receipt['spamVerdict']['status'] == 'FAIL' or | |
receipt['virusVerdict']['status'] == 'FAIL') | |
if is_spam: | |
print('SPAM message:', message_id) | |
else: | |
print('HAM message:', message_id) | |
return is_spam | |
def spam_filter(event, context): | |
'''Reject all spam emails''' | |
print('Starting - inbound-ses-spam-filter') | |
if is_spam(event, context): | |
return {'disposition': 'stop_rule'} | |
def spam_trap_filter(event, context): | |
'''Collect All Spam Emails''' | |
print('Starting - inbound-ses-spam-trap-filter') | |
if not is_spam(event, context): | |
return {'disposition': 'stop_rule'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment