Skip to content

Commit

Permalink
added in more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alpalwal committed Oct 1, 2018
1 parent 028171a commit 7e5602e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ def lambda_handler(event, context):
print(raw_message) #CW Logs prints JSON prettier. Printing this for easier recreation.

try:
try:
try: # Normally the event comes through as json
source_message = json.loads(raw_message)
except: # If the event comes through as a dict, take it as it comes
except: # If the event comes through as a dict, take it as it comes (this is usually when testing locally)
source_message = raw_message
# Check for source. Transform it to "Dome9" format if it's not originating from Dome9.
# This expects that GD is triggering lambda via SNS. This is neeeded for running cross-region GD events.
if "source" in source_message and source_message["source"] == "aws.guardduty": # GuardDuty event source via CW Events
text_output_array.append("Event Source: GuardDuty\n")
gd_transform_module = importlib.import_module('transform_gd_event')
found_action, text_output, source_message = gd_transform_module.transform_gd_event(source_message)
found_action, text_output, source_message = gd_transform_module.transform_gd_event(source_message) # Transform the event from GuardDuty to the Dome9 format
text_output_array.append(text_output)
if not found_action:
print(text_output_array)
Expand All @@ -51,7 +51,7 @@ def lambda_handler(event, context):
text_output_array.append("Handle_event failed\n")
text_output_array.append(str(e))


# After the bot is called, post it to SNS for output logging
if SNS_TOPIC_ARN != '' and post_to_sns:
sendEvent(text_output_array,SNS_TOPIC_ARN)

Expand Down

0 comments on commit 7e5602e

Please sign in to comment.