forked from p15670423/monkey
Island: Rename dest -> target
This commit is contained in:
parent
2aa79331e3
commit
c632b9b77b
|
@ -37,17 +37,17 @@ class handle_ping_scan_event:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
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_target_machine_os(target_machine, event)
|
||||||
self._update_nodes(dest_machine, event)
|
self._update_nodes(target_machine, event)
|
||||||
except (RetrievalError, StorageError, TypeError, UnknownRecordError):
|
except (RetrievalError, StorageError, TypeError, UnknownRecordError):
|
||||||
logger.exception("Unable to process ping scan data")
|
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:
|
try:
|
||||||
dest_machines = self._machine_repository.get_machines_by_ip(event.target)
|
target_machines = self._machine_repository.get_machines_by_ip(event.target)
|
||||||
return dest_machines[0]
|
return target_machines[0]
|
||||||
except UnknownRecordError:
|
except UnknownRecordError:
|
||||||
machine = Machine(
|
machine = Machine(
|
||||||
id=self._machine_repository.get_new_id(),
|
id=self._machine_repository.get_new_id(),
|
||||||
|
@ -56,17 +56,17 @@ class handle_ping_scan_event:
|
||||||
self._machine_repository.upsert_machine(machine)
|
self._machine_repository.upsert_machine(machine)
|
||||||
return 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:
|
if event.os is not None and machine.operating_system is None:
|
||||||
machine.operating_system = event.os
|
machine.operating_system = event.os
|
||||||
self._machine_repository.upsert_machine(machine)
|
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)
|
src_machine = self._get_source_machine(event)
|
||||||
|
|
||||||
# Update or create the node
|
# Update or create the node
|
||||||
self._node_repository.upsert_communication(
|
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:
|
def _get_source_machine(self, event: PingScanEvent) -> Machine:
|
||||||
|
|
Loading…
Reference in New Issue