From c5e142a5005a7dc7df51bb9a0946f68cf6bbdaa4 Mon Sep 17 00:00:00 2001 From: Nick Todd Date: Wed, 13 Mar 2024 17:43:56 +0000 Subject: [PATCH] 2299: Remove calls to corrupt. --- src/primaite/simulator/file_system/file.py | 3 --- .../simulator/file_system/file_system_item_abc.py | 2 +- src/primaite/simulator/file_system/folder.py | 10 +++++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/primaite/simulator/file_system/file.py b/src/primaite/simulator/file_system/file.py index 9331c40c..10819522 100644 --- a/src/primaite/simulator/file_system/file.py +++ b/src/primaite/simulator/file_system/file.py @@ -162,9 +162,6 @@ class File(FileSystemItemABC): if self.previous_hash is None: self.previous_hash = current_hash - # if the previous hash and current hash do not match, mark file as corrupted - if self.previous_hash is not current_hash: - self.corrupt() return True def repair(self) -> bool: diff --git a/src/primaite/simulator/file_system/file_system_item_abc.py b/src/primaite/simulator/file_system/file_system_item_abc.py index 32f5f6be..c89152b4 100644 --- a/src/primaite/simulator/file_system/file_system_item_abc.py +++ b/src/primaite/simulator/file_system/file_system_item_abc.py @@ -156,7 +156,7 @@ class FileSystemItemABC(SimComponent): @abstractmethod def check_hash(self) -> bool: """ - Checks the has of the file to detect any changes. + Checks the hash of the file to detect any changes. For current implementation, any change in file hash means it is compromised. diff --git a/src/primaite/simulator/file_system/folder.py b/src/primaite/simulator/file_system/folder.py index 6ebd8d14..192d8627 100644 --- a/src/primaite/simulator/file_system/folder.py +++ b/src/primaite/simulator/file_system/folder.py @@ -381,17 +381,17 @@ class Folder(FileSystemItemABC): return False # iterate through the files and run a check hash - no_corrupted_files = True + # no_corrupted_files = True for file_id in self.files: file = self.get_file_by_id(file_uuid=file_id) file.check_hash() - if file.health_status == FileSystemItemHealthStatus.CORRUPT: - no_corrupted_files = False + # if file.health_status == FileSystemItemHealthStatus.CORRUPT: + # no_corrupted_files = False # if one file in the folder is corrupted, set the folder status to corrupted - if not no_corrupted_files: - self.corrupt() + # if not no_corrupted_files: + # self.corrupt() self.sys_log.info(f"Checking hash of folder {self.name} (id: {self.uuid})") return True