Island, UI: bugfixes related to stopping of the agents
This commit is contained in:
parent
11735b4f89
commit
a567041fba
|
@ -108,7 +108,7 @@ class Monkey(Document):
|
||||||
|
|
||||||
def get_parent(self):
|
def get_parent(self):
|
||||||
if self.has_parent():
|
if self.has_parent():
|
||||||
Monkey.objects(guid=self.parent[0][0]).first()
|
return Monkey.objects(guid=self.parent[0][0]).first()
|
||||||
else:
|
else:
|
||||||
raise ParentNotFoundError(f"No parent was found for agent with GUID {self.guid}")
|
raise ParentNotFoundError(f"No parent was found for agent with GUID {self.guid}")
|
||||||
|
|
||||||
|
|
|
@ -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.auth.auth import jwt_required
|
||||||
from monkey_island.cc.resources.utils.semaphores import AGENT_KILLING_SEMAPHORE
|
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):
|
class StopAllAgents(flask_restful.Resource):
|
||||||
|
@ -20,4 +20,4 @@ class StopAllAgents(flask_restful.Resource):
|
||||||
return make_response({}, 400)
|
return make_response({}, 400)
|
||||||
|
|
||||||
def get(self, monkey_guid):
|
def get(self, monkey_guid):
|
||||||
return {"stop_agent": was_monkey_killed(monkey_guid)}
|
return {"stop_agent": should_agent_die(monkey_guid)}
|
||||||
|
|
|
@ -24,12 +24,12 @@ def set_stop_all(time: float):
|
||||||
|
|
||||||
|
|
||||||
def should_agent_die(guid: int) -> bool:
|
def should_agent_die(guid: int) -> bool:
|
||||||
monkey = Monkey.objects(guid=guid).first()
|
monkey = Monkey.objects(guid=str(guid)).first()
|
||||||
return _is_monkey_marked_dead(monkey) or _is_monkey_killed_manually()
|
return _is_monkey_marked_dead(monkey) or _is_monkey_killed_manually(monkey)
|
||||||
|
|
||||||
|
|
||||||
def _is_monkey_marked_dead(monkey: Monkey) -> bool:
|
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:
|
def _is_monkey_killed_manually(monkey: Monkey) -> bool:
|
||||||
|
|
|
@ -84,7 +84,7 @@ class MapPageComponent extends AuthComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
killAllMonkeys = () => {
|
killAllMonkeys = () => {
|
||||||
this.authFetch('/api/agent_control/stop-all-agents',
|
this.authFetch('/api/monkey_control/stop-all-agents',
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
|
|
Loading…
Reference in New Issue