diff --git a/monkey/monkey_island/cc/repository/i_node_repository.py b/monkey/monkey_island/cc/repository/i_node_repository.py new file mode 100644 index 000000000..b8ea0c49d --- /dev/null +++ b/monkey/monkey_island/cc/repository/i_node_repository.py @@ -0,0 +1,35 @@ +from abc import ABC, abstractmethod +from typing import Sequence + +from monkey_island.cc.models import CommunicationType, MachineID, Node + + +class INodeRepository(ABC): + """A repository used to store and retrieve `Node` objects""" + + @abstractmethod + def upsert_communication( + self, src: MachineID, dst: MachineID, communication_type: CommunicationType + ): + """ + Insert or update a node connection + + Insert or update data about how network nodes are able to communicate. Nodes are identified + by MachineID and store information about all outbound connections to other machines. By + providing a source machine, target machine, and how they communicated, nodes in this + repository can be created if they don't exist or updated if they do. + + :param src: The machine that the connection or communication originated from + :param dst: The machine that the src communicated with + :param communication_type: The way the machines communicated + :raises StorageError: If an error occurred while attempting to upsert the Node + """ + + @abstractmethod + def get_nodes(self) -> Sequence[Node]: + """ + Return all nodes that are stored in the repository + + :return: All known Nodes + :raises RetrievalError: If an error occurred while attempting to retrieve the nodes + """ diff --git a/vulture_allowlist.py b/vulture_allowlist.py index ea46d5b2b..265d675d7 100644 --- a/vulture_allowlist.py +++ b/vulture_allowlist.py @@ -259,6 +259,10 @@ IMachineRepository.get_machine_by_hardware_id IMachineRepository.get_machines_by_ip INetworkMapRepository.get_map INetworkMapRepository.save_netmap +INodeRepository +INodeRepository.upsert_communication +INodeRepository.communication_type +INodeRepository.get_nodes IReportRepository ISimulationRepository.save_simulation ISimulationRepository.get_simulation