Merge branch 'develop' into release/1.7

This commit is contained in:
Shay Nehmad 2019-10-07 10:39:47 +03:00
commit 3174a97d3e
1 changed files with 14 additions and 6 deletions

View File

@ -29,7 +29,7 @@ class TelemetryFeed(flask_restful.Resource):
try: try:
return \ return \
{ {
'telemetries': [TelemetryFeed.get_displayed_telemetry(telem) for telem in telemetries], 'telemetries': [TelemetryFeed.get_displayed_telemetry(telem) for telem in telemetries if TelemetryFeed],
'timestamp': datetime.now().isoformat() 'timestamp': datetime.now().isoformat()
} }
except KeyError as err: except KeyError as err:
@ -45,9 +45,18 @@ class TelemetryFeed(flask_restful.Resource):
'id': telem['_id'], 'id': telem['_id'],
'timestamp': telem['timestamp'].strftime('%d/%m/%Y %H:%M:%S'), 'timestamp': telem['timestamp'].strftime('%d/%m/%Y %H:%M:%S'),
'hostname': monkey.get('hostname', default_hostname) if monkey else default_hostname, 'hostname': monkey.get('hostname', default_hostname) if monkey else default_hostname,
'brief': TELEM_PROCESS_DICT[telem['telem_category']](telem) 'brief': TelemetryFeed.get_telem_brief(telem)
} }
@staticmethod
def get_telem_brief(telem):
telem_brief_parser = TelemetryFeed.get_telem_brief_parser_by_category(telem['telem_category'])
return telem_brief_parser(telem)
@staticmethod
def get_telem_brief_parser_by_category(telem_category):
return TELEM_PROCESS_DICT[telem_category]
@staticmethod @staticmethod
def get_tunnel_telem_brief(telem): def get_tunnel_telem_brief(telem):
tunnel = telem['data']['proxy'] tunnel = telem['data']['proxy']
@ -94,8 +103,8 @@ class TelemetryFeed(flask_restful.Resource):
telem['data']['ip']) telem['data']['ip'])
@staticmethod @staticmethod
def get_attack_telem_brief(telem): def should_show_brief(telem):
return 'Monkey collected MITRE ATT&CK info.' return telem['telem_category'] in TELEM_PROCESS_DICT
TELEM_PROCESS_DICT = \ TELEM_PROCESS_DICT = \
@ -106,6 +115,5 @@ TELEM_PROCESS_DICT = \
'scan': TelemetryFeed.get_scan_telem_brief, 'scan': TelemetryFeed.get_scan_telem_brief,
'system_info': TelemetryFeed.get_systeminfo_telem_brief, 'system_info': TelemetryFeed.get_systeminfo_telem_brief,
'trace': TelemetryFeed.get_trace_telem_brief, 'trace': TelemetryFeed.get_trace_telem_brief,
'post_breach': TelemetryFeed.get_post_breach_telem_brief, 'post_breach': TelemetryFeed.get_post_breach_telem_brief
'attack': TelemetryFeed.get_attack_telem_brief
} }