Island: Rename dest -> target

This commit is contained in:
Mike Salvatore 2022-09-29 15:09:29 -04:00
parent 2aa79331e3
commit c632b9b77b
1 changed files with 9 additions and 9 deletions

View File

@ -37,17 +37,17 @@ class handle_ping_scan_event:
return
try:
dest_machine = self._get_destination_machine(event)
target_machine = self._get_target_machine(event)
self._update_destination_machine_os(dest_machine, event)
self._update_nodes(dest_machine, event)
self._update_target_machine_os(target_machine, event)
self._update_nodes(target_machine, event)
except (RetrievalError, StorageError, TypeError, UnknownRecordError):
logger.exception("Unable to process ping scan data")
def _get_destination_machine(self, event: PingScanEvent) -> Machine:
def _get_target_machine(self, event: PingScanEvent) -> Machine:
try:
dest_machines = self._machine_repository.get_machines_by_ip(event.target)
return dest_machines[0]
target_machines = self._machine_repository.get_machines_by_ip(event.target)
return target_machines[0]
except UnknownRecordError:
machine = Machine(
id=self._machine_repository.get_new_id(),
@ -56,17 +56,17 @@ class handle_ping_scan_event:
self._machine_repository.upsert_machine(machine)
return machine
def _update_destination_machine_os(self, machine: Machine, event: PingScanEvent):
def _update_target_machine_os(self, machine: Machine, event: PingScanEvent):
if event.os is not None and machine.operating_system is None:
machine.operating_system = event.os
self._machine_repository.upsert_machine(machine)
def _update_nodes(self, dest_machine, event):
def _update_nodes(self, target_machine, event):
src_machine = self._get_source_machine(event)
# Update or create the node
self._node_repository.upsert_communication(
src_machine.id, dest_machine.id, CommunicationType.SCANNED
src_machine.id, target_machine.id, CommunicationType.SCANNED
)
def _get_source_machine(self, event: PingScanEvent) -> Machine: