зеркало из https://github.com/mozilla/MozDef.git
Fixup zoom mq plugin to set start_time if empty string
This commit is contained in:
Родитель
cce6d78095
Коммит
11fe76292f
|
@ -74,6 +74,11 @@ class message(object):
|
|||
# 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 @@ class TestZoomFixupPlugin():
|
|||
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 @@ class TestZoomFixupPlugin():
|
|||
'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,10 +273,10 @@ class TestZoomFixupPlugin():
|
|||
'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='
|
||||
|
@ -285,3 +284,53 @@ class TestZoomFixupPlugin():
|
|||
}
|
||||
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 == {}
|
||||
|
|
Загрузка…
Ссылка в новой задаче