Skip to content
Snippets Groups Projects
Commit 39f25507 authored by Edward Hicks's avatar Edward Hicks 🎱
Browse files

state clearly that we're ignoring messages that don't pass the sanity

checks
parent 931db43e
No related merge requests found
Pipeline #91830 passed
......@@ -113,36 +113,34 @@ def sanityCheckMessage(body, payload):
# Make sure message came from the right SNS channel
if body['TopicArn'] != Session['topicArn']:
raise Exception("Message came from an invalid SNS topic")
raise Exception("Message came from an invalid SNS topic - ignoring it")
# Make sure message subject matches what we're expecting
try:
if not re.match('^WHAWS ', body['Subject']):
raise Exception("Message has invalid subject '"+str(body['Subject'])+"'")
raise Exception("Message has invalid subject '"+str(body['Subject'])+"' - ignoring it")
except KeyError:
raise Exception("Message is missing a subject")
raise Exception("Message is missing a subject - ignoring it")
# Verify that the payload includes a valid operation to perform
try:
if payload['operation'] not in Config['events']:
raise Exception("Message has invalid operation '"+str(payload['operation'])+"'")
raise Exception("Message has invalid operation '"+str(payload['operation'])+"' - ignoring it")
except KeyError:
raise Exception("Message is missing an operation to perform")
raise Exception("Message is missing an operation to perform - ignoring it")
# Verify that the payload includes a timestamp
try:
if not isinstance(payload['timestamp'], numbers.Number) or payload['timestamp'] < 0:
raise Exception("Message has invalid timestamp '"+str(payload['timestamp'])+"'")
raise Exception("Message has invalid timestamp '"+str(payload['timestamp'])+"' - ignoring it")
except KeyError:
raise Exception("Message is missing a timestamp")
raise Exception("Message is missing a timestamp - ignoring it")
# 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):
raise Exception("UID provided is not a number")
if uid > 65535 or uid < 100:
raise Exception("UID provided is an invalid user")
if not isinstance(uid, numbers.Number) or uid > 65535 or uid < 100:
raise Exception("Message provides an invalid UID - ignoring it")
except KeyError:
# payload['params']['uid'] doesn't exist to be invalid
pass
......
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