Skip to content
Permalink
Browse files

Fixup zoom mq plugin to set start_time if empty string

  • Loading branch information
pwnbus committed Feb 11, 2020
1 parent cce6d78 commit 11fe76292f9aa4fa62ca69fd6a9989cd4d55c2bb
Showing with 60 additions and 6 deletions.
  1. +5 −0 mq/plugins/zoom_fixup.py
  2. +55 −6 tests/mq/plugins/test_zoom_fixup.py
@@ -74,6 +74,11 @@ def onMessage(self, message, metadata):
# JMESPath likes to silently return a None object
if mappedvalue is not None:
newmessage['details'][key] = mappedvalue
# Some zoom messages don't contain details.start_time
# so we set it to original start time
if key_exists('details.start_time', newmessage) and key_exists('details.original_sched_start_time', newmessage):
if newmessage['details']['start_time'] == '':
newmessage['details']['start_time'] = newmessage['details']['original_sched_start_time']

else:
newmessage = None
@@ -197,7 +197,7 @@ def test_remove_duplicate_account_id(self):
assert retmessage == expected_message
assert retmeta == {}

def differing_account_ids(self):
def test_differing_account_ids(self):
msg = {
'summary': 'zoom_event',
'source': 'api_aws_lambda',
@@ -229,20 +229,19 @@ def differing_account_ids(self):
'severity': 'info',
'eventsource': 'MozDef-EF-zoom',
'tags': 'zoom',
'processname': 'zoom_webhook_api',
'details': {
'event': 'meeting.created',
'account_id': 'ABCDEFG123456',
'meeting_account_id': 'HIJKLMN123456',
'id': '123456789',
'type': '2',
'uuid': 'aodij/OWIE9241048='

}
}
assert retmessage == expected_message
assert retmeta == {}

def multiple_tags_check(self):
def test_multiple_tags_check(self):
msg = {
'summary': 'zoom_event',
'source': 'api_aws_lambda',
@@ -274,14 +273,64 @@ def multiple_tags_check(self):
'severity': 'info',
'eventsource': 'MozDef-EF-zoom',
'tags': ['zoom', 'MozDef-EF-zoom-dev'],
'processname': 'zoom_webhook_api',
'details': {
'event': 'meeting.created',
'account_id': 'ABCDEFG123456',
'meeting_account_id': 'HIJKLMN123456',
'event': 'meeting.created',
'id': '123456789',
'type': '2',
'uuid': 'aodij/OWIE9241048='
}
}
assert retmessage == expected_message
assert retmeta == {}

def test_start_time_empty_string(self):
msg = {
'summary': 'zoom_event',
'source': 'api_aws_lambda',
'hostname': 'zoom_host',
'severity': 'info',
'eventsource': 'MozDef-EF-zoom',
'tags': ['zoom', 'MozDef-EF-zoom-dev'],
'category': 'zoom',
'details': {
'event': 'meeting.created',
'payload': {
'account_id': 'ABCDEFG123456',
'object': {
'account_id': 'HIJKLMN123456',
'id': '123456789',
'type': '2',
'uuid': 'aodij/OWIE9241048=',
'start_time': ''
},
'old_object': {
'start_time': '2020-02-11T20:25:30Z'
}
}
}
}
(retmessage, retmeta) = self.plugin.onMessage(msg, {})

expected_message = {
'summary': 'zoom: meeting.created',
'category': 'zoom',
'source': 'api_aws_lambda',
'hostname': 'zoom_host',
'severity': 'info',
'eventsource': 'MozDef-EF-zoom',
'tags': ['zoom', 'MozDef-EF-zoom-dev'],
'processname': 'zoom_webhook_api',
'details': {
'account_id': 'ABCDEFG123456',
'event': 'meeting.created',
'id': '123456789',
'type': '2',
'uuid': 'aodij/OWIE9241048=',
'original_sched_start_time': '2020-02-11T20:25:30Z',
'start_time': '2020-02-11T20:25:30Z',
}
}
assert retmessage == expected_message
assert retmeta == {}

0 comments on commit 11fe762

Please sign in to comment.
You can’t perform that action at this time.