Island: renamed MONKEY_KILLING_SEMAPHORE to monkey_killing_mutex, because it better represent the purpose and is not a const
This commit is contained in:
parent
492334fbd0
commit
92c0152b4e
|
@ -4,14 +4,14 @@ import flask_restful
|
||||||
from flask import make_response, request
|
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_mutex
|
||||||
from monkey_island.cc.services.infection_lifecycle import set_stop_all, should_agent_die
|
from monkey_island.cc.services.infection_lifecycle import set_stop_all, should_agent_die
|
||||||
|
|
||||||
|
|
||||||
class StopAllAgents(flask_restful.Resource):
|
class StopAllAgents(flask_restful.Resource):
|
||||||
@jwt_required
|
@jwt_required
|
||||||
def post(self):
|
def post(self):
|
||||||
with AGENT_KILLING_SEMAPHORE:
|
with agent_killing_mutex:
|
||||||
data = json.loads(request.data)
|
data = json.loads(request.data)
|
||||||
if data["kill_time"]:
|
if data["kill_time"]:
|
||||||
set_stop_all(data["kill_time"])
|
set_stop_all(data["kill_time"])
|
||||||
|
|
|
@ -8,7 +8,7 @@ from flask import request
|
||||||
from monkey_island.cc.database import mongo
|
from monkey_island.cc.database import mongo
|
||||||
from monkey_island.cc.models.monkey_ttl import create_monkey_ttl_document
|
from monkey_island.cc.models.monkey_ttl import create_monkey_ttl_document
|
||||||
from monkey_island.cc.resources.blackbox.utils.telem_store import TestTelemStore
|
from monkey_island.cc.resources.blackbox.utils.telem_store import TestTelemStore
|
||||||
from monkey_island.cc.resources.utils.semaphores import AGENT_KILLING_SEMAPHORE
|
from monkey_island.cc.resources.utils.semaphores import agent_killing_mutex
|
||||||
from monkey_island.cc.server_utils.consts import DEFAULT_MONKEY_TTL_EXPIRY_DURATION_IN_SECONDS
|
from monkey_island.cc.server_utils.consts import DEFAULT_MONKEY_TTL_EXPIRY_DURATION_IN_SECONDS
|
||||||
from monkey_island.cc.services.config import ConfigService
|
from monkey_island.cc.services.config import ConfigService
|
||||||
from monkey_island.cc.services.edge.edge import EdgeService
|
from monkey_island.cc.services.edge.edge import EdgeService
|
||||||
|
@ -67,7 +67,7 @@ class Monkey(flask_restful.Resource):
|
||||||
# Called on monkey wakeup to initialize local configuration
|
# Called on monkey wakeup to initialize local configuration
|
||||||
@TestTelemStore.store_exported_telem
|
@TestTelemStore.store_exported_telem
|
||||||
def post(self, **kw):
|
def post(self, **kw):
|
||||||
with AGENT_KILLING_SEMAPHORE:
|
with agent_killing_mutex:
|
||||||
monkey_json = json.loads(request.data)
|
monkey_json = json.loads(request.data)
|
||||||
monkey_json["creds"] = []
|
monkey_json["creds"] = []
|
||||||
monkey_json["dead"] = False
|
monkey_json["dead"] = False
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from gevent.lock import BoundedSemaphore
|
from gevent.lock import BoundedSemaphore
|
||||||
|
|
||||||
# Semaphore avoids race condition between monkeys
|
# Mutex avoids race condition between monkeys
|
||||||
# being marked dead and monkey waking up as alive
|
# being marked dead and monkey waking up as alive
|
||||||
AGENT_KILLING_SEMAPHORE = BoundedSemaphore()
|
agent_killing_mutex = BoundedSemaphore()
|
||||||
|
|
Loading…
Reference in New Issue