revert-Remove unnecessary use of comprehension

This commit is contained in:
shubhendra 2020-12-05 14:24:49 +05:30
parent 9f48a54529
commit 32593b2105
2 changed files with 7 additions and 5 deletions

View File

@ -87,18 +87,20 @@ class Monkey(flask_restful.Resource):
parent = monkey_json.get('parent') parent = monkey_json.get('parent')
parent_to_add = (monkey_json.get('guid'), None) # default values in case of manual run parent_to_add = (monkey_json.get('guid'), None) # default values in case of manual run
if parent and parent != monkey_json.get('guid'): # current parent is known if parent and parent != monkey_json.get('guid'): # current parent is known
exploit_telem = list(mongo.db.telemetry.find({'telem_category': {'$eq': 'exploit'}, exploit_telem = [x for x in
mongo.db.telemetry.find({'telem_category': {'$eq': 'exploit'},
'data.result': {'$eq': True}, 'data.result': {'$eq': True},
'data.machine.ip_addr': {'$in': monkey_json['ip_addresses']}, 'data.machine.ip_addr': {'$in': monkey_json['ip_addresses']},
'monkey_guid': {'$eq': parent}})) 'monkey_guid': {'$eq': parent}})]
if 1 == len(exploit_telem): if 1 == len(exploit_telem):
parent_to_add = (exploit_telem[0].get('monkey_guid'), exploit_telem[0].get('data').get('exploiter')) parent_to_add = (exploit_telem[0].get('monkey_guid'), exploit_telem[0].get('data').get('exploiter'))
else: else:
parent_to_add = (parent, None) parent_to_add = (parent, None)
elif (not parent or parent == monkey_json.get('guid')) and 'ip_addresses' in monkey_json: elif (not parent or parent == monkey_json.get('guid')) and 'ip_addresses' in monkey_json:
exploit_telem = list(mongo.db.telemetry.find({'telem_category': {'$eq': 'exploit'}, exploit_telem = [x for x in
mongo.db.telemetry.find({'telem_category': {'$eq': 'exploit'},
'data.result': {'$eq': True}, 'data.result': {'$eq': True},
'data.machine.ip_addr': {'$in': monkey_json['ip_addresses']}})) 'data.machine.ip_addr': {'$in': monkey_json['ip_addresses']}})]
if 1 == len(exploit_telem): if 1 == len(exploit_telem):
parent_to_add = (exploit_telem[0].get('monkey_guid'), exploit_telem[0].get('data').get('exploiter')) parent_to_add = (exploit_telem[0].get('monkey_guid'), exploit_telem[0].get('data').get('exploiter'))

View File

@ -63,7 +63,7 @@ class DisplayedEdgeService:
@staticmethod @staticmethod
def services_to_displayed_services(services, for_report=False): def services_to_displayed_services(services, for_report=False):
if for_report: if for_report:
return list(services) return [x for x in services]
else: else:
return [x + ": " + (services[x]['name'] if 'name' in services[x] else 'unknown') for x in services] return [x + ": " + (services[x]['name'] if 'name' in services[x] else 'unknown') for x in services]