Island: Add comments in services and models

These comments explain/elaborate on changes needed for DAL implementation
This commit is contained in:
vakarisz 2022-05-18 17:31:19 +03:00
parent 4bbd998197
commit 3b0ec975d2
4 changed files with 5 additions and 0 deletions

View File

@ -1,6 +1,7 @@
from mongoengine import Document, FloatField from mongoengine import Document, FloatField
# TODO rename to Simulation, add other metadata
class AgentControls(Document): class AgentControls(Document):
# Timestamp of the last "kill all agents" command # Timestamp of the last "kill all agents" command

View File

@ -32,6 +32,8 @@ def get_report() -> dict:
return _decode_dot_char_before_mongo_insert(decrypt_dict(sensitive_fields, 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): def _encode_dot_char_before_mongo_insert(report_dict):
""" """
mongodb doesn't allow for '.' and '$' in a key's name, this function replaces the '.' mongodb doesn't allow for '.' and '$' in a key's name, this function replaces the '.'

View File

@ -7,6 +7,7 @@ from mongoengine import Document, EmbeddedDocumentListField
from monkey_island.cc.models.zero_trust.event import Event from monkey_island.cc.models.zero_trust.event import Event
# TODO just move events to the finding and remove this collection
class MonkeyFindingDetails(Document): class MonkeyFindingDetails(Document):
# SCHEMA # SCHEMA
events = EmbeddedDocumentListField(document_type=Event, required=False) events = EmbeddedDocumentListField(document_type=Event, required=False)

View File

@ -15,6 +15,7 @@ logger = logging.getLogger(__name__)
def set_stop_all(time: float): def set_stop_all(time: float):
# This will use Agent and Simulation repositories
for monkey in Monkey.objects(): for monkey in Monkey.objects():
monkey.config.should_stop = True monkey.config.should_stop = True
monkey.save() monkey.save()