From 32593b2105bc0dba7e6f7c3275faa946a4ae98c0 Mon Sep 17 00:00:00 2001 From: shubhendra Date: Sat, 5 Dec 2020 14:24:49 +0530 Subject: [PATCH] revert-Remove unnecessary use of comprehension --- monkey/monkey_island/cc/resources/monkey.py | 10 ++++++---- .../monkey_island/cc/services/edge/displayed_edge.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/monkey/monkey_island/cc/resources/monkey.py b/monkey/monkey_island/cc/resources/monkey.py index cd570903d..0962e6dd5 100644 --- a/monkey/monkey_island/cc/resources/monkey.py +++ b/monkey/monkey_island/cc/resources/monkey.py @@ -87,18 +87,20 @@ class Monkey(flask_restful.Resource): parent = monkey_json.get('parent') 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 - 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.machine.ip_addr': {'$in': monkey_json['ip_addresses']}, - 'monkey_guid': {'$eq': parent}})) + 'monkey_guid': {'$eq': parent}})] if 1 == len(exploit_telem): parent_to_add = (exploit_telem[0].get('monkey_guid'), exploit_telem[0].get('data').get('exploiter')) else: parent_to_add = (parent, None) 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.machine.ip_addr': {'$in': monkey_json['ip_addresses']}})) + 'data.machine.ip_addr': {'$in': monkey_json['ip_addresses']}})] if 1 == len(exploit_telem): parent_to_add = (exploit_telem[0].get('monkey_guid'), exploit_telem[0].get('data').get('exploiter')) diff --git a/monkey/monkey_island/cc/services/edge/displayed_edge.py b/monkey/monkey_island/cc/services/edge/displayed_edge.py index 9b9509ea6..f7a0664bf 100644 --- a/monkey/monkey_island/cc/services/edge/displayed_edge.py +++ b/monkey/monkey_island/cc/services/edge/displayed_edge.py @@ -63,7 +63,7 @@ class DisplayedEdgeService: @staticmethod def services_to_displayed_services(services, for_report=False): if for_report: - return list(services) + return [x for x in services] else: return [x + ": " + (services[x]['name'] if 'name' in services[x] else 'unknown') for x in services]