diff --git a/monkey/monkey_island/cc/models/machine.py b/monkey/monkey_island/cc/models/machine.py index 686e677b6..b09e8bf99 100644 --- a/monkey/monkey_island/cc/models/machine.py +++ b/monkey/monkey_island/cc/models/machine.py @@ -20,7 +20,7 @@ class Machine(MutableInfectionMonkeyBaseModel): hardware_id: Optional[HardwareID] """An identifier generated by the agent that uniquely identifies a machine""" - network_interfaces: Sequence[IPv4Interface] + network_interfaces: Sequence[IPv4Interface] = Field(default_factory=tuple) """The machine's networking interfaces""" operating_system: Optional[OperatingSystem] diff --git a/monkey/tests/unit_tests/monkey_island/cc/models/test_machine.py b/monkey/tests/unit_tests/monkey_island/cc/models/test_machine.py index 8414cd9d6..a2e712a25 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/models/test_machine.py +++ b/monkey/tests/unit_tests/monkey_island/cc/models/test_machine.py @@ -141,6 +141,15 @@ def test_network_interfaces_sequence_is_immutable(): assert not isinstance(m.network_interfaces, MutableSequence) +def test_network_interfaces_default(): + missing_network_interfaces_dict = MACHINE_OBJECT_DICT.copy() + del missing_network_interfaces_dict["network_interfaces"] + + m = Machine(**missing_network_interfaces_dict) + + assert len(m.network_interfaces) == 0 + + def test_operating_system_set_valid_value(): m = Machine(**MACHINE_OBJECT_DICT)