Skip to content
Snippets Groups Projects
Commit d0ea95df authored by Edward Hicks's avatar Edward Hicks :8ball:
Browse files

true/false != True/False

parent 5f86eac1
No related branches found
No related tags found
No related merge requests found
Pipeline #91828 passed
......@@ -114,50 +114,50 @@ def sanityCheckMessage(body, payload):
# Make sure message came from the right SNS channel
if body['TopicArn'] != Session['topicArn']:
printLog("Message came from an invalid SNS topic")
return false
return False
# Make sure message subject matches what we're expecting
try:
if not re.match('^WHAWS ', body['Subject']):
printLog("Message has invalid subject '"+str(body['Subject'])+"'")
return false
return False
except KeyError:
printLog("Message is missing a subject")
return false
return False
# Verify that the payload includes a valid operation to perform
try:
if payload['operation'] not in Config['events']:
printLog("Message has invalid operation '"+str(payload['operation'])+"'")
return false
return False
except KeyError:
printLog("Message is missing an operation to perform")
return false
return False
# Verify that the payload includes a timestamp
try:
if not isinstance(payload['timestamp'], numbers.Number) or payload['timestamp'] < 0:
printLog("Message has invalid timestamp '"+str(payload['timestamp'])+"'")
return false
return False
except KeyError:
printLog("Message is missing a timestamp")
return false
return False
# If the data section includes a UID (i.e. kill_my_phpcgi) then make sure it's valid
try:
uid = payload['params']['uid']
if not isinstance(uid, numbers.Number):
printLog("UID provided is not a number")
return false
return False
if uid > 65535 or uid < 100:
printLog("UID provided is an invalid user")
return false
return False
except KeyError:
# payload['params']['uid'] doesn't exist to be invalid
pass
# If we got this far then it's good
return true
return True
parser = argparse.ArgumentParser(description=bcolors.HEADER+'Amazon SNS event daemon'+bcolors.ENDC)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment