From 842e59f5964612213787e21a459368e136276cf3 Mon Sep 17 00:00:00 2001 From: Marek Wolan Date: Thu, 11 Jan 2024 15:40:37 +0000 Subject: [PATCH] Database patch --- .../simulator/system/services/database/database_service.py | 5 +++++ src/primaite/simulator/system/software.py | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/primaite/simulator/system/services/database/database_service.py b/src/primaite/simulator/system/services/database/database_service.py index 7c665b9a..1cdd0390 100644 --- a/src/primaite/simulator/system/services/database/database_service.py +++ b/src/primaite/simulator/system/services/database/database_service.py @@ -247,3 +247,8 @@ class DatabaseService(Service): if timestep == 1: self.backup_database() return super().apply_timestep(timestep) + + def _update_patch_status(self) -> None: + super()._update_patch_status() + if self._patching_countdown is None: + self.restore_backup() diff --git a/src/primaite/simulator/system/software.py b/src/primaite/simulator/system/software.py index a58e4c48..b7c0bd9b 100644 --- a/src/primaite/simulator/system/software.py +++ b/src/primaite/simulator/system/software.py @@ -193,8 +193,9 @@ class Software(SimComponent): def patch(self) -> None: """Perform a patch on the software.""" - self._patching_countdown = self.patching_duration - self.set_health_state(SoftwareHealthState.PATCHING) + if self.health_state_actual in (SoftwareHealthState.COMPROMISED, SoftwareHealthState.GOOD): + self._patching_countdown = self.patching_duration + self.set_health_state(SoftwareHealthState.PATCHING) def _update_patch_status(self) -> None: """Update the patch status of the software."""