From df049ef842ff53c9d0419634ac72d1f462e2cae6 Mon Sep 17 00:00:00 2001 From: Shay Nehmad Date: Tue, 7 May 2019 18:59:07 +0300 Subject: [PATCH] Fixed report page not using the new API Even though all monkeys have finished, the report page still used the dead=False check instead of is_dead. So even though all monkeys were dead or MIA the report page said that some monkeys are still runnning. --- monkey/monkey_island/cc/services/node.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/monkey/monkey_island/cc/services/node.py b/monkey/monkey_island/cc/services/node.py index a9dde51e2..442fb391a 100644 --- a/monkey/monkey_island/cc/services/node.py +++ b/monkey/monkey_island/cc/services/node.py @@ -68,7 +68,7 @@ class NodeService: def get_node_label(node): domain_name = "" if node["domain_name"]: - domain_name = " ("+node["domain_name"]+")" + domain_name = " (" + node["domain_name"] + ")" return node["os"]["version"] + " : " + node["ip_addresses"][0] + domain_name @staticmethod @@ -106,7 +106,8 @@ class NodeService: @staticmethod def get_monkey_critical_services(monkey_id): - critical_services = mongo.db.monkey.find_one({'_id': monkey_id}, {'critical_services': 1}).get('critical_services', []) + critical_services = mongo.db.monkey.find_one({'_id': monkey_id}, {'critical_services': 1}).get( + 'critical_services', []) return critical_services @staticmethod @@ -296,7 +297,8 @@ class NodeService: @staticmethod def is_any_monkey_alive(): - return models.Monkey.objects(dead=False).count() > 0 + all_monkeys = models.Monkey.objects() + return any(not monkey.is_dead() for monkey in all_monkeys) @staticmethod def is_any_monkey_exists():