From f7a30e460893c3fc5865770c6fcb0448fd2a10d0 Mon Sep 17 00:00:00 2001 From: Kekoa Kaaikala Date: Thu, 29 Sep 2022 20:03:11 +0000 Subject: [PATCH] Island: Raise errors if repositories do not exist --- monkey/monkey_island/cc/services/reporting/report.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/monkey/monkey_island/cc/services/reporting/report.py b/monkey/monkey_island/cc/services/reporting/report.py index d0d41cbb1..aa70b3895 100644 --- a/monkey/monkey_island/cc/services/reporting/report.py +++ b/monkey/monkey_island/cc/services/reporting/report.py @@ -139,8 +139,10 @@ class ReportService: @classmethod def get_accessible_machines(cls, machine: Machine): - if cls._node_repository is None or cls._machine_repository is None: - return [] + if cls._node_repository is None: + raise RuntimeError("Node repository does not exist") + elif cls._machine_repository is None: + raise RuntimeError("Machine repository does not exist") nodes = cls._node_repository.get_nodes() machine_iter = (node for node in nodes if node.machine_id == machine.id) @@ -155,7 +157,7 @@ class ReportService: @classmethod def get_all_machines(cls) -> Iterable[Machine]: if cls._machine_repository is None: - return iter(()) + raise RuntimeError("Machine repository does not exist") machines = cls._machine_repository.get_machines() t1, t2 = tee(machines)