From 3b0ec975d2e00fabe6c24d1eb3c12324f0fdb47f Mon Sep 17 00:00:00 2001 From: vakarisz Date: Wed, 18 May 2022 17:31:19 +0300 Subject: [PATCH] Island: Add comments in services and models These comments explain/elaborate on changes needed for DAL implementation --- monkey/monkey_island/cc/models/agent_controls/agent_controls.py | 1 + monkey/monkey_island/cc/models/report/report_dal.py | 2 ++ .../cc/models/zero_trust/monkey_finding_details.py | 1 + monkey/monkey_island/cc/services/infection_lifecycle.py | 1 + 4 files changed, 5 insertions(+) diff --git a/monkey/monkey_island/cc/models/agent_controls/agent_controls.py b/monkey/monkey_island/cc/models/agent_controls/agent_controls.py index 37903d5e7..93caa8433 100644 --- a/monkey/monkey_island/cc/models/agent_controls/agent_controls.py +++ b/monkey/monkey_island/cc/models/agent_controls/agent_controls.py @@ -1,6 +1,7 @@ from mongoengine import Document, FloatField +# TODO rename to Simulation, add other metadata class AgentControls(Document): # Timestamp of the last "kill all agents" command diff --git a/monkey/monkey_island/cc/models/report/report_dal.py b/monkey/monkey_island/cc/models/report/report_dal.py index be7bade9e..3b7ca65e9 100644 --- a/monkey/monkey_island/cc/models/report/report_dal.py +++ b/monkey/monkey_island/cc/models/report/report_dal.py @@ -32,6 +32,8 @@ def get_report() -> dict: return _decode_dot_char_before_mongo_insert(decrypt_dict(sensitive_fields, report_dict)) +# TODO remove this unnecessary encoding. I think these are legacy methods from back in the day +# when usernames were used as keys. If not, we shouldn't use unknown data as keys. def _encode_dot_char_before_mongo_insert(report_dict): """ mongodb doesn't allow for '.' and '$' in a key's name, this function replaces the '.' diff --git a/monkey/monkey_island/cc/models/zero_trust/monkey_finding_details.py b/monkey/monkey_island/cc/models/zero_trust/monkey_finding_details.py index 3568e0ee1..3aa3d0b87 100644 --- a/monkey/monkey_island/cc/models/zero_trust/monkey_finding_details.py +++ b/monkey/monkey_island/cc/models/zero_trust/monkey_finding_details.py @@ -7,6 +7,7 @@ from mongoengine import Document, EmbeddedDocumentListField from monkey_island.cc.models.zero_trust.event import Event +# TODO just move events to the finding and remove this collection class MonkeyFindingDetails(Document): # SCHEMA events = EmbeddedDocumentListField(document_type=Event, required=False) diff --git a/monkey/monkey_island/cc/services/infection_lifecycle.py b/monkey/monkey_island/cc/services/infection_lifecycle.py index 865602168..2da5e90b7 100644 --- a/monkey/monkey_island/cc/services/infection_lifecycle.py +++ b/monkey/monkey_island/cc/services/infection_lifecycle.py @@ -15,6 +15,7 @@ logger = logging.getLogger(__name__) def set_stop_all(time: float): + # This will use Agent and Simulation repositories for monkey in Monkey.objects(): monkey.config.should_stop = True monkey.save()