#2404 rename software patch to fix

This commit is contained in:
Cristian-VM2
2024-03-26 10:51:33 +00:00
parent 600dc3f016
commit 944b248300
22 changed files with 64 additions and 66 deletions

View File

@@ -158,7 +158,7 @@ green_ier_blocked: -0.001
# Patching / Reset durations # Patching / Reset durations
os_patching_duration: 5 # The time taken to patch the OS os_patching_duration: 5 # The time taken to patch the OS
node_reset_duration: 5 # The time taken to reset a node (hardware) node_reset_duration: 5 # The time taken to reset a node (hardware)
service_patching_duration: 5 # The time taken to patch a service service_fixing_duration: 5 # The time taken to patch a service
file_system_repairing_limit: 5 # The time take to repair the file system file_system_repairing_limit: 5 # The time take to repair the file system
file_system_restoring_limit: 5 # The time take to restore the file system file_system_restoring_limit: 5 # The time take to restore the file system
file_system_scanning_limit: 5 # The time taken to scan the file system file_system_scanning_limit: 5 # The time taken to scan the file system

View File

@@ -5634,7 +5634,7 @@
"green_ier_blocked": -0.001, "green_ier_blocked": -0.001,
"os_patching_duration": 5, "os_patching_duration": 5,
"node_reset_duration": 5, "node_reset_duration": 5,
"service_patching_duration": 5, "service_fixing_duration": 5,
"file_system_repairing_limit": 5, "file_system_repairing_limit": 5,
"file_system_restoring_limit": 5, "file_system_restoring_limit": 5,
"file_system_scanning_limit": 5 "file_system_scanning_limit": 5

View File

@@ -48,7 +48,7 @@ class "ActiveNode" as primaite.nodes.active_node.ActiveNode {
file_system_state_actual : GOOD file_system_state_actual : GOOD
file_system_state_observed : REPAIRING, RESTORING, GOOD file_system_state_observed : REPAIRING, RESTORING, GOOD
ip_address : str ip_address : str
patching_count : int fixing_count : int
software_state software_state
software_state : GOOD software_state : GOOD
set_file_system_state(file_system_state: FileSystemState) -> None set_file_system_state(file_system_state: FileSystemState) -> None
@@ -353,10 +353,10 @@ class "SB3Agent" as primaite.agents.sb3.SB3Agent {
} }
class "Service" as primaite.common.service.Service { class "Service" as primaite.common.service.Service {
name : str name : str
patching_count : int fixing_count : int
port : str port : str
software_state : GOOD software_state : GOOD
reduce_patching_count() -> None reduce_fixing_count() -> None
} }
class "ServiceNode" as primaite.nodes.service_node.ServiceNode { class "ServiceNode" as primaite.nodes.service_node.ServiceNode {
services : Dict[str, Service] services : Dict[str, Service]
@@ -455,7 +455,7 @@ class "TrainingConfig" as primaite.config.training_config.TrainingConfig {
sb3_output_verbose_level sb3_output_verbose_level
scanning : float scanning : float
seed : Optional[int] seed : Optional[int]
service_patching_duration : int service_fixing_duration : int
session_type session_type
time_delay : int time_delay : int
from_dict(config_dict: Dict[str, Any]) -> TrainingConfig from_dict(config_dict: Dict[str, Any]) -> TrainingConfig

View File

@@ -244,7 +244,7 @@ agents:
- type: NODE_SERVICE_RESTART - type: NODE_SERVICE_RESTART
- type: NODE_SERVICE_DISABLE - type: NODE_SERVICE_DISABLE
- type: NODE_SERVICE_ENABLE - type: NODE_SERVICE_ENABLE
- type: NODE_SERVICE_PATCH - type: NODE_SERVICE_FIX
- type: NODE_FILE_SCAN - type: NODE_FILE_SCAN
- type: NODE_FILE_CHECKHASH - type: NODE_FILE_CHECKHASH
- type: NODE_FILE_DELETE - type: NODE_FILE_DELETE
@@ -339,7 +339,7 @@ agents:
folder_id: 0 folder_id: 0
file_id: 0 file_id: 0
13: 13:
action: "NODE_SERVICE_PATCH" action: "NODE_SERVICE_FIX"
options: options:
node_id: 2 node_id: 2
service_id: 0 service_id: 0

View File

@@ -246,7 +246,7 @@ agents:
- type: NODE_SERVICE_RESTART - type: NODE_SERVICE_RESTART
- type: NODE_SERVICE_DISABLE - type: NODE_SERVICE_DISABLE
- type: NODE_SERVICE_ENABLE - type: NODE_SERVICE_ENABLE
- type: NODE_SERVICE_PATCH - type: NODE_SERVICE_FIX
- type: NODE_FILE_SCAN - type: NODE_FILE_SCAN
- type: NODE_FILE_CHECKHASH - type: NODE_FILE_CHECKHASH
- type: NODE_FILE_DELETE - type: NODE_FILE_DELETE
@@ -341,7 +341,7 @@ agents:
folder_id: 0 folder_id: 0
file_id: 0 file_id: 0
13: 13:
action: "NODE_SERVICE_PATCH" action: "NODE_SERVICE_FIX"
options: options:
node_id: 2 node_id: 2
service_id: 0 service_id: 0
@@ -797,7 +797,7 @@ agents:
- type: NODE_SERVICE_RESTART - type: NODE_SERVICE_RESTART
- type: NODE_SERVICE_DISABLE - type: NODE_SERVICE_DISABLE
- type: NODE_SERVICE_ENABLE - type: NODE_SERVICE_ENABLE
- type: NODE_SERVICE_PATCH - type: NODE_SERVICE_FIX
- type: NODE_FILE_SCAN - type: NODE_FILE_SCAN
- type: NODE_FILE_CHECKHASH - type: NODE_FILE_CHECKHASH
- type: NODE_FILE_DELETE - type: NODE_FILE_DELETE
@@ -892,7 +892,7 @@ agents:
folder_id: 0 folder_id: 0
file_id: 0 file_id: 0
13: 13:
action: "NODE_SERVICE_PATCH" action: "NODE_SERVICE_FIX"
options: options:
node_id: 2 node_id: 2
service_id: 0 service_id: 0

View File

@@ -156,12 +156,12 @@ class NodeServiceEnableAction(NodeServiceAbstractAction):
self.verb: str = "enable" self.verb: str = "enable"
class NodeServicePatchAction(NodeServiceAbstractAction): class NodeServiceFixAction(NodeServiceAbstractAction):
"""Action which patches a service.""" """Action which fixes a service."""
def __init__(self, manager: "ActionManager", num_nodes: int, num_services: int, **kwargs) -> None: def __init__(self, manager: "ActionManager", num_nodes: int, num_services: int, **kwargs) -> None:
super().__init__(manager=manager, num_nodes=num_nodes, num_services=num_services) super().__init__(manager=manager, num_nodes=num_nodes, num_services=num_services)
self.verb: str = "patch" self.verb: str = "fix"
class NodeApplicationAbstractAction(AbstractAction): class NodeApplicationAbstractAction(AbstractAction):
@@ -216,7 +216,7 @@ class NodeApplicationFixAction(NodeApplicationAbstractAction):
def __init__(self, manager: "ActionManager", num_nodes: int, num_applications: int, **kwargs) -> None: def __init__(self, manager: "ActionManager", num_nodes: int, num_applications: int, **kwargs) -> None:
super().__init__(manager=manager, num_nodes=num_nodes, num_applications=num_applications) super().__init__(manager=manager, num_nodes=num_nodes, num_applications=num_applications)
self.verb: str = "patch" self.verb: str = "fix"
class NodeFolderAbstractAction(AbstractAction): class NodeFolderAbstractAction(AbstractAction):
@@ -653,7 +653,7 @@ class ActionManager:
"NODE_SERVICE_RESTART": NodeServiceRestartAction, "NODE_SERVICE_RESTART": NodeServiceRestartAction,
"NODE_SERVICE_DISABLE": NodeServiceDisableAction, "NODE_SERVICE_DISABLE": NodeServiceDisableAction,
"NODE_SERVICE_ENABLE": NodeServiceEnableAction, "NODE_SERVICE_ENABLE": NodeServiceEnableAction,
"NODE_SERVICE_PATCH": NodeServicePatchAction, "NODE_SERVICE_FIX": NodeServiceFixAction,
"NODE_APPLICATION_EXECUTE": NodeApplicationExecuteAction, "NODE_APPLICATION_EXECUTE": NodeApplicationExecuteAction,
"NODE_APPLICATION_SCAN": NodeApplicationScanAction, "NODE_APPLICATION_SCAN": NodeApplicationScanAction,
"NODE_APPLICATION_CLOSE": NodeApplicationCloseAction, "NODE_APPLICATION_CLOSE": NodeApplicationCloseAction,

View File

@@ -304,8 +304,8 @@ class DatabaseService(Service):
self.backup_database() self.backup_database()
return super().apply_timestep(timestep) return super().apply_timestep(timestep)
def _update_patch_status(self) -> None: def _update_fix_status(self) -> None:
"""Perform a database restore when the patching countdown is finished.""" """Perform a database restore when the patching countdown is finished."""
super()._update_patch_status() super()._update_fix_status()
if self._patching_countdown is None: if self._fixing_countdown is None:
self.restore_backup() self.restore_backup()

View File

@@ -82,7 +82,7 @@ class Software(SimComponent):
"The health state of the software visible to the red agent." "The health state of the software visible to the red agent."
criticality: SoftwareCriticality = SoftwareCriticality.LOWEST criticality: SoftwareCriticality = SoftwareCriticality.LOWEST
"The criticality level of the software." "The criticality level of the software."
patching_count: int = 0 fixing_count: int = 0
"The count of patches applied to the software, defaults to 0." "The count of patches applied to the software, defaults to 0."
scanning_count: int = 0 scanning_count: int = 0
"The count of times the software has been scanned, defaults to 0." "The count of times the software has been scanned, defaults to 0."
@@ -96,9 +96,9 @@ class Software(SimComponent):
"The FileSystem of the Node the Software is installed on." "The FileSystem of the Node the Software is installed on."
folder: Optional[Folder] = None folder: Optional[Folder] = None
"The folder on the file system the Software uses." "The folder on the file system the Software uses."
patching_duration: int = 2 fixing_duration: int = 2
"The number of ticks it takes to patch the software." "The number of ticks it takes to patch the software."
_patching_countdown: Optional[int] = None _fixing_countdown: Optional[int] = None
"Current number of ticks left to patch the software." "Current number of ticks left to patch the software."
def _init_request_manager(self) -> RequestManager: def _init_request_manager(self) -> RequestManager:
@@ -117,9 +117,9 @@ class Software(SimComponent):
), ),
) )
rm.add_request( rm.add_request(
"patch", "fix",
RequestType( RequestType(
func=lambda request, context: RequestResponse.from_bool(self.patch()), func=lambda request, context: RequestResponse.from_bool(self.fix()),
), ),
) )
rm.add_request("scan", RequestType(func=lambda request, context: RequestResponse.from_bool(self.scan()))) rm.add_request("scan", RequestType(func=lambda request, context: RequestResponse.from_bool(self.scan())))
@@ -149,7 +149,7 @@ class Software(SimComponent):
"health_state_actual": self.health_state_actual.value, "health_state_actual": self.health_state_actual.value,
"health_state_visible": self.health_state_visible.value, "health_state_visible": self.health_state_visible.value,
"criticality": self.criticality.value, "criticality": self.criticality.value,
"patching_count": self.patching_count, "fixing_count": self.fixing_count,
"scanning_count": self.scanning_count, "scanning_count": self.scanning_count,
"revealed_to_red": self.revealed_to_red, "revealed_to_red": self.revealed_to_red,
} }
@@ -194,21 +194,21 @@ class Software(SimComponent):
self.health_state_visible = self.health_state_actual self.health_state_visible = self.health_state_actual
return True return True
def patch(self) -> bool: def fix(self) -> bool:
"""Perform a patch on the software.""" """Perform a fix on the software."""
if self.health_state_actual in (SoftwareHealthState.COMPROMISED, SoftwareHealthState.GOOD): if self.health_state_actual in (SoftwareHealthState.COMPROMISED, SoftwareHealthState.GOOD):
self._patching_countdown = self.patching_duration self._fixing_countdown = self.fixing_duration
self.set_health_state(SoftwareHealthState.PATCHING) self.set_health_state(SoftwareHealthState.PATCHING)
return True return True
return False return False
def _update_patch_status(self) -> None: def _update_fix_status(self) -> None:
"""Update the patch status of the software.""" """Update the fix status of the software."""
self._patching_countdown -= 1 self._fixing_countdown -= 1
if self._patching_countdown <= 0: if self._fixing_countdown <= 0:
self.set_health_state(SoftwareHealthState.GOOD) self.set_health_state(SoftwareHealthState.GOOD)
self._patching_countdown = None self._fixing_countdown = None
self.patching_count += 1 self.fixing_count += 1
def reveal_to_red(self) -> None: def reveal_to_red(self) -> None:
"""Reveals the software to the red agent.""" """Reveals the software to the red agent."""
@@ -222,7 +222,7 @@ class Software(SimComponent):
""" """
super().apply_timestep(timestep) super().apply_timestep(timestep)
if self.health_state_actual == SoftwareHealthState.PATCHING: if self.health_state_actual == SoftwareHealthState.PATCHING:
self._update_patch_status() self._update_fix_status()
class IOSoftware(Software): class IOSoftware(Software):

View File

@@ -155,7 +155,7 @@ agents:
- type: NODE_SERVICE_RESTART - type: NODE_SERVICE_RESTART
- type: NODE_SERVICE_DISABLE - type: NODE_SERVICE_DISABLE
- type: NODE_SERVICE_ENABLE - type: NODE_SERVICE_ENABLE
- type: NODE_SERVICE_PATCH - type: NODE_SERVICE_FIX
- type: NODE_FILE_SCAN - type: NODE_FILE_SCAN
- type: NODE_FILE_CHECKHASH - type: NODE_FILE_CHECKHASH
- type: NODE_FILE_DELETE - type: NODE_FILE_DELETE
@@ -250,7 +250,7 @@ agents:
folder_id: 1 folder_id: 1
file_id: 0 file_id: 0
13: 13:
action: "NODE_SERVICE_PATCH" action: "NODE_SERVICE_FIX"
options: options:
node_id: 2 node_id: 2
service_id: 0 service_id: 0

View File

@@ -159,7 +159,7 @@ agents:
- type: NODE_SERVICE_RESTART - type: NODE_SERVICE_RESTART
- type: NODE_SERVICE_DISABLE - type: NODE_SERVICE_DISABLE
- type: NODE_SERVICE_ENABLE - type: NODE_SERVICE_ENABLE
- type: NODE_SERVICE_PATCH - type: NODE_SERVICE_FIX
- type: NODE_FILE_SCAN - type: NODE_FILE_SCAN
- type: NODE_FILE_CHECKHASH - type: NODE_FILE_CHECKHASH
- type: NODE_FILE_DELETE - type: NODE_FILE_DELETE
@@ -254,7 +254,7 @@ agents:
folder_id: 1 folder_id: 1
file_id: 0 file_id: 0
13: 13:
action: "NODE_SERVICE_PATCH" action: "NODE_SERVICE_FIX"
options: options:
node_id: 2 node_id: 2
service_id: 0 service_id: 0

View File

@@ -166,7 +166,7 @@ agents:
- type: NODE_SERVICE_RESTART - type: NODE_SERVICE_RESTART
- type: NODE_SERVICE_DISABLE - type: NODE_SERVICE_DISABLE
- type: NODE_SERVICE_ENABLE - type: NODE_SERVICE_ENABLE
- type: NODE_SERVICE_PATCH - type: NODE_SERVICE_FIX
- type: NODE_FILE_SCAN - type: NODE_FILE_SCAN
- type: NODE_FILE_CHECKHASH - type: NODE_FILE_CHECKHASH
- type: NODE_FILE_DELETE - type: NODE_FILE_DELETE
@@ -261,7 +261,7 @@ agents:
folder_id: 1 folder_id: 1
file_id: 0 file_id: 0
13: 13:
action: "NODE_SERVICE_PATCH" action: "NODE_SERVICE_FIX"
options: options:
node_id: 2 node_id: 2
service_id: 0 service_id: 0
@@ -610,7 +610,7 @@ agents:
- type: NODE_SERVICE_RESTART - type: NODE_SERVICE_RESTART
- type: NODE_SERVICE_DISABLE - type: NODE_SERVICE_DISABLE
- type: NODE_SERVICE_ENABLE - type: NODE_SERVICE_ENABLE
- type: NODE_SERVICE_PATCH - type: NODE_SERVICE_FIX
- type: NODE_FILE_SCAN - type: NODE_FILE_SCAN
- type: NODE_FILE_CHECKHASH - type: NODE_FILE_CHECKHASH
- type: NODE_FILE_DELETE - type: NODE_FILE_DELETE
@@ -705,7 +705,7 @@ agents:
folder_id: 1 folder_id: 1
file_id: 0 file_id: 0
13: 13:
action: "NODE_SERVICE_PATCH" action: "NODE_SERVICE_FIX"
options: options:
node_id: 2 node_id: 2
service_id: 0 service_id: 0

View File

@@ -244,7 +244,7 @@ agents:
- type: NODE_SERVICE_RESTART - type: NODE_SERVICE_RESTART
- type: NODE_SERVICE_DISABLE - type: NODE_SERVICE_DISABLE
- type: NODE_SERVICE_ENABLE - type: NODE_SERVICE_ENABLE
- type: NODE_SERVICE_PATCH - type: NODE_SERVICE_FIX
- type: NODE_FILE_SCAN - type: NODE_FILE_SCAN
- type: NODE_FILE_CHECKHASH - type: NODE_FILE_CHECKHASH
- type: NODE_FILE_DELETE - type: NODE_FILE_DELETE
@@ -339,7 +339,7 @@ agents:
folder_id: 0 folder_id: 0
file_id: 0 file_id: 0
13: 13:
action: "NODE_SERVICE_PATCH" action: "NODE_SERVICE_FIX"
options: options:
node_id: 2 node_id: 2
service_id: 0 service_id: 0

View File

@@ -169,7 +169,7 @@ agents:
- type: NODE_SERVICE_RESTART - type: NODE_SERVICE_RESTART
- type: NODE_SERVICE_DISABLE - type: NODE_SERVICE_DISABLE
- type: NODE_SERVICE_ENABLE - type: NODE_SERVICE_ENABLE
- type: NODE_SERVICE_PATCH - type: NODE_SERVICE_FIX
- type: NODE_FILE_SCAN - type: NODE_FILE_SCAN
- type: NODE_FILE_CHECKHASH - type: NODE_FILE_CHECKHASH
- type: NODE_FILE_DELETE - type: NODE_FILE_DELETE
@@ -264,7 +264,7 @@ agents:
folder_id: 1 folder_id: 1
file_id: 0 file_id: 0
13: 13:
action: "NODE_SERVICE_PATCH" action: "NODE_SERVICE_FIX"
options: options:
node_id: 2 node_id: 2
service_id: 0 service_id: 0

View File

@@ -167,7 +167,7 @@ agents:
- type: NODE_SERVICE_RESTART - type: NODE_SERVICE_RESTART
- type: NODE_SERVICE_DISABLE - type: NODE_SERVICE_DISABLE
- type: NODE_SERVICE_ENABLE - type: NODE_SERVICE_ENABLE
- type: NODE_SERVICE_PATCH - type: NODE_SERVICE_FIX
- type: NODE_FILE_SCAN - type: NODE_FILE_SCAN
- type: NODE_FILE_CHECKHASH - type: NODE_FILE_CHECKHASH
- type: NODE_FILE_DELETE - type: NODE_FILE_DELETE
@@ -262,7 +262,7 @@ agents:
folder_id: 1 folder_id: 1
file_id: 0 file_id: 0
13: 13:
action: "NODE_SERVICE_PATCH" action: "NODE_SERVICE_FIX"
options: options:
node_id: 2 node_id: 2
service_id: 0 service_id: 0

File diff suppressed because one or more lines are too long

View File

@@ -475,7 +475,7 @@ def game_and_agent():
{"type": "NODE_SERVICE_RESTART"}, {"type": "NODE_SERVICE_RESTART"},
{"type": "NODE_SERVICE_DISABLE"}, {"type": "NODE_SERVICE_DISABLE"},
{"type": "NODE_SERVICE_ENABLE"}, {"type": "NODE_SERVICE_ENABLE"},
{"type": "NODE_SERVICE_PATCH"}, {"type": "NODE_SERVICE_FIX"},
{"type": "NODE_APPLICATION_EXECUTE"}, {"type": "NODE_APPLICATION_EXECUTE"},
{"type": "NODE_APPLICATION_SCAN"}, {"type": "NODE_APPLICATION_SCAN"},
{"type": "NODE_APPLICATION_CLOSE"}, {"type": "NODE_APPLICATION_CLOSE"},

View File

@@ -65,9 +65,9 @@ def test_node_service_scan_integration(game_and_agent: Tuple[PrimaiteGame, Proxy
assert svc.health_state_visible == SoftwareHealthState.COMPROMISED assert svc.health_state_visible == SoftwareHealthState.COMPROMISED
def test_node_service_patch_integration(game_and_agent: Tuple[PrimaiteGame, ProxyAgent]): def test_node_service_fix_integration(game_and_agent: Tuple[PrimaiteGame, ProxyAgent]):
""" """
Test that the NodeServicePatchAction can form a request and that it is accepted by the simulation. Test that the NodeServiceFixAction can form a request and that it is accepted by the simulation.
When you initiate a patch action, the software health state turns to PATCHING, then after a few steps, it goes When you initiate a patch action, the software health state turns to PATCHING, then after a few steps, it goes
to GOOD. to GOOD.
@@ -79,7 +79,7 @@ def test_node_service_patch_integration(game_and_agent: Tuple[PrimaiteGame, Prox
svc.health_state_actual = SoftwareHealthState.COMPROMISED svc.health_state_actual = SoftwareHealthState.COMPROMISED
# 2: Apply a patch action # 2: Apply a patch action
action = ("NODE_SERVICE_PATCH", {"node_id": 1, "service_id": 0}) action = ("NODE_SERVICE_FIX", {"node_id": 1, "service_id": 0})
agent.store_action(action) agent.store_action(action)
game.step() game.step()

View File

@@ -23,7 +23,7 @@ def test_successful_application_requests(example_network):
resp_1 = net.apply_request(["node", "client_1", "application", "TestApplication", "scan"]) resp_1 = net.apply_request(["node", "client_1", "application", "TestApplication", "scan"])
assert resp_1 == RequestResponse(status="success", data={}) assert resp_1 == RequestResponse(status="success", data={})
resp_2 = net.apply_request(["node", "client_1", "application", "TestApplication", "patch"]) resp_2 = net.apply_request(["node", "client_1", "application", "TestApplication", "fix"])
assert resp_2 == RequestResponse(status="success", data={}) assert resp_2 == RequestResponse(status="success", data={})
resp_3 = net.apply_request(["node", "client_1", "application", "TestApplication", "compromise"]) resp_3 = net.apply_request(["node", "client_1", "application", "TestApplication", "compromise"])
assert resp_3 == RequestResponse(status="success", data={}) assert resp_3 == RequestResponse(status="success", data={})
@@ -46,7 +46,7 @@ def test_successful_service_requests(example_network):
"resume", "resume",
"compromise", "compromise",
"scan", "scan",
"patch", "fix",
]: ]:
resp_1 = net.apply_request(["node", "server_1", "service", "TestService", verb]) resp_1 = net.apply_request(["node", "server_1", "service", "TestService", verb])
assert resp_1 == RequestResponse(status="success", data={}) assert resp_1 == RequestResponse(status="success", data={})

View File

@@ -46,5 +46,5 @@ def test_application_describe_states(application):
application.set_health_state(SoftwareHealthState.COMPROMISED) application.set_health_state(SoftwareHealthState.COMPROMISED)
assert SoftwareHealthState.COMPROMISED.value == application.describe_state().get("health_state_actual") assert SoftwareHealthState.COMPROMISED.value == application.describe_state().get("health_state_actual")
application.patch() application.fix()
assert SoftwareHealthState.PATCHING.value == application.describe_state().get("health_state_actual") assert SoftwareHealthState.PATCHING.value == application.describe_state().get("health_state_actual")

View File

@@ -99,8 +99,6 @@ def test_query_when_client_is_closed(database_client_on_computer):
assert database_client.query(sql="test") is False assert database_client.query(sql="test") is False
def test_query_fail_to_connect(database_client_on_computer):
"""Database client query should return False if the connect attempt fails.""" """Database client query should return False if the connect attempt fails."""
database_client, computer = database_client_on_computer database_client, computer = database_client_on_computer

View File

@@ -80,12 +80,12 @@ def test_service_enable(service):
assert service.operating_state == ServiceOperatingState.STOPPED assert service.operating_state == ServiceOperatingState.STOPPED
def test_service_patch(service): def test_service_fix(service):
"""Test that a service can be patched and that it takes two timesteps to complete.""" """Test that a service can be fixed and that it takes two timesteps to complete."""
service.start() service.start()
assert service.health_state_actual == SoftwareHealthState.GOOD assert service.health_state_actual == SoftwareHealthState.GOOD
service.apply_request(["patch"]) service.apply_request(["fix"])
assert service.health_state_actual == SoftwareHealthState.PATCHING assert service.health_state_actual == SoftwareHealthState.PATCHING
service.apply_timestep(1) service.apply_timestep(1)
assert service.health_state_actual == SoftwareHealthState.PATCHING assert service.health_state_actual == SoftwareHealthState.PATCHING

View File

@@ -136,16 +136,16 @@ def test_compromised_service_remains_compromised(service):
assert service.health_state_actual == SoftwareHealthState.COMPROMISED assert service.health_state_actual == SoftwareHealthState.COMPROMISED
def test_service_patching(service): def test_service_fixing(service):
service.start() service.start()
assert service.health_state_actual == SoftwareHealthState.GOOD assert service.health_state_actual == SoftwareHealthState.GOOD
service.set_health_state(SoftwareHealthState.COMPROMISED) service.set_health_state(SoftwareHealthState.COMPROMISED)
service.patch() service.fix()
assert service.health_state_actual == SoftwareHealthState.PATCHING assert service.health_state_actual == SoftwareHealthState.PATCHING
for i in range(service.patching_duration + 1): for i in range(service.fixing_duration + 1):
service.apply_timestep(i) service.apply_timestep(i)
assert service.health_state_actual == SoftwareHealthState.GOOD assert service.health_state_actual == SoftwareHealthState.GOOD