Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snseventd
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OTDI Middleware
snseventd
Commits
39f25507
Commit
39f25507
authored
4 years ago
by
Edward Hicks
🎱
Browse files
Options
Downloads
Patches
Plain Diff
state clearly that we're ignoring messages that don't pass the sanity
checks
parent
931db43e
Loading
Loading
No related merge requests found
Pipeline
#91830
passed
4 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
snseventd.py
+9
-11
9 additions, 11 deletions
snseventd.py
with
9 additions
and
11 deletions
snseventd.py
+
9
−
11
View file @
39f25507
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment