From 9031bfb8881f4c4698e296cad3926ee8e0cc97ac Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 7 Dec 2021 14:43:40 +0200 Subject: [PATCH] Island: append should agent die check to also check if monkey is marked dead in configuration --- .../monkey_island/cc/services/infection_lifecycle.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/services/infection_lifecycle.py b/monkey/monkey_island/cc/services/infection_lifecycle.py index ca6e36924..23207e982 100644 --- a/monkey/monkey_island/cc/services/infection_lifecycle.py +++ b/monkey/monkey_island/cc/services/infection_lifecycle.py @@ -23,8 +23,16 @@ def set_stop_all(time: float): agent_controls.save() -def was_monkey_killed(guid: int) -> bool: +def should_agent_die(guid: int) -> bool: monkey = Monkey.objects(guid=guid).first() + return _is_monkey_marked_dead(monkey) or _is_monkey_killed_manually() + + +def _is_monkey_marked_dead(monkey: Monkey) -> bool: + return monkey.config.alive + + +def _is_monkey_killed_manually(monkey: Monkey) -> bool: if monkey.has_parent(): launch_timestamp = monkey.get_parent().launch_time else: