Island, UI: bugfixes related to stopping of the agents

This commit is contained in:
VakarisZ 2021-12-08 10:14:46 +02:00
parent 11735b4f89
commit a567041fba
4 changed files with 7 additions and 7 deletions

View File

@ -108,7 +108,7 @@ class Monkey(Document):
def get_parent(self):
if self.has_parent():
Monkey.objects(guid=self.parent[0][0]).first()
return Monkey.objects(guid=self.parent[0][0]).first()
else:
raise ParentNotFoundError(f"No parent was found for agent with GUID {self.guid}")

View File

@ -5,7 +5,7 @@ from flask import make_response, request
from monkey_island.cc.resources.auth.auth import jwt_required
from monkey_island.cc.resources.utils.semaphores import AGENT_KILLING_SEMAPHORE
from monkey_island.cc.services.infection_lifecycle import set_stop_all, was_monkey_killed
from monkey_island.cc.services.infection_lifecycle import set_stop_all, should_agent_die
class StopAllAgents(flask_restful.Resource):
@ -20,4 +20,4 @@ class StopAllAgents(flask_restful.Resource):
return make_response({}, 400)
def get(self, monkey_guid):
return {"stop_agent": was_monkey_killed(monkey_guid)}
return {"stop_agent": should_agent_die(monkey_guid)}

View File

@ -24,12 +24,12 @@ def set_stop_all(time: float):
def should_agent_die(guid: int) -> bool:
monkey = Monkey.objects(guid=guid).first()
return _is_monkey_marked_dead(monkey) or _is_monkey_killed_manually()
monkey = Monkey.objects(guid=str(guid)).first()
return _is_monkey_marked_dead(monkey) or _is_monkey_killed_manually(monkey)
def _is_monkey_marked_dead(monkey: Monkey) -> bool:
return monkey.config.alive
return not monkey.config.alive
def _is_monkey_killed_manually(monkey: Monkey) -> bool:

View File

@ -84,7 +84,7 @@ class MapPageComponent extends AuthComponent {
}
killAllMonkeys = () => {
this.authFetch('/api/agent_control/stop-all-agents',
this.authFetch('/api/monkey_control/stop-all-agents',
{
method: 'POST',
headers: {'Content-Type': 'application/json'},