Backport 3.3.1 fixes into Core
This commit is contained in:
@@ -69,8 +69,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -74,8 +74,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -88,8 +88,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -160,8 +160,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -102,8 +102,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -161,8 +161,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -77,8 +77,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -81,8 +81,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -152,8 +152,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
@@ -666,8 +666,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -151,8 +151,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -81,8 +81,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -155,8 +155,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -103,8 +103,8 @@ agents:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
|
||||
@@ -69,7 +69,7 @@ def test_file_scan_action(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAgent
|
||||
|
||||
file.corrupt()
|
||||
assert file.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
action = (
|
||||
"node_file_scan",
|
||||
|
||||
@@ -52,12 +52,12 @@ def test_folder_scan_action(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAge
|
||||
|
||||
folder = client_1.file_system.get_folder(folder_name="downloads")
|
||||
assert folder.health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
folder.corrupt()
|
||||
|
||||
assert folder.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
action = (
|
||||
"node_folder_scan",
|
||||
|
||||
@@ -32,11 +32,11 @@ def test_file_observation(simulation):
|
||||
assert dog_file_obs.space["health_status"] == spaces.Discrete(6)
|
||||
|
||||
observation_state = dog_file_obs.observe(simulation.describe_state())
|
||||
assert observation_state.get("health_status") == 1 # good initial
|
||||
assert observation_state.get("health_status") == 0 # initially unset
|
||||
|
||||
file.corrupt()
|
||||
observation_state = dog_file_obs.observe(simulation.describe_state())
|
||||
assert observation_state.get("health_status") == 1 # scan file so this changes
|
||||
assert observation_state.get("health_status") == 0 # still default unset value because no scan happened
|
||||
|
||||
file.scan()
|
||||
file.apply_timestep(0) # apply time step
|
||||
@@ -63,11 +63,11 @@ def test_folder_observation(simulation):
|
||||
|
||||
observation_state = root_folder_obs.observe(simulation.describe_state())
|
||||
assert observation_state.get("FILES") is not None
|
||||
assert observation_state.get("health_status") == 1
|
||||
assert observation_state.get("health_status") == 0 # initially unset
|
||||
|
||||
file.corrupt() # corrupt just the file
|
||||
observation_state = root_folder_obs.observe(simulation.describe_state())
|
||||
assert observation_state.get("health_status") == 1 # scan folder to change this
|
||||
assert observation_state.get("health_status") == 0 # still unset as no scan occurred yet
|
||||
|
||||
folder.scan()
|
||||
for i in range(folder.scan_duration + 1):
|
||||
|
||||
@@ -275,7 +275,7 @@ def test_node_file_scan_integration(game_and_agent: Tuple[PrimaiteGame, ProxyAge
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
file = client_1.file_system.get_file("downloads", "cat.png")
|
||||
assert file.health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
# 2: perform a scan and make sure nothing has changed
|
||||
action = (
|
||||
|
||||
@@ -17,12 +17,7 @@ def test_file_observation():
|
||||
dog_file_obs = FileObservation(
|
||||
where=["network", "nodes", pc.hostname, "file_system", "folders", "root", "files", "dog.png"],
|
||||
include_num_access=False,
|
||||
file_system_requires_scan=True,
|
||||
file_system_requires_scan=False,
|
||||
)
|
||||
assert dog_file_obs.observe(state) == {"health_status": 1}
|
||||
assert dog_file_obs.space == spaces.Dict({"health_status": spaces.Discrete(6)})
|
||||
|
||||
|
||||
# TODO:
|
||||
# def test_file_num_access():
|
||||
# ...
|
||||
|
||||
@@ -163,7 +163,7 @@ def test_restore_backup_without_updating_scan(uc2_network):
|
||||
|
||||
db_service.db_file.corrupt() # corrupt the db
|
||||
assert db_service.db_file.health_status == FileSystemItemHealthStatus.CORRUPT # db file is actually corrupt
|
||||
assert db_service.db_file.visible_health_status == FileSystemItemHealthStatus.GOOD # not scanned yet
|
||||
assert db_service.db_file.visible_health_status == FileSystemItemHealthStatus.NONE # not scanned yet
|
||||
|
||||
db_service.db_file.scan() # scan the db file
|
||||
|
||||
@@ -190,7 +190,7 @@ def test_restore_backup_after_deleting_file_without_updating_scan(uc2_network):
|
||||
|
||||
db_service.db_file.corrupt() # corrupt the db
|
||||
assert db_service.db_file.health_status == FileSystemItemHealthStatus.CORRUPT # db file is actually corrupt
|
||||
assert db_service.db_file.visible_health_status == FileSystemItemHealthStatus.GOOD # not scanned yet
|
||||
assert db_service.db_file.visible_health_status == FileSystemItemHealthStatus.NONE # not scanned yet
|
||||
|
||||
db_service.db_file.scan() # scan the db file
|
||||
|
||||
|
||||
@@ -69,8 +69,8 @@ class TestFileSystemRequiresScan:
|
||||
wildcard_list:
|
||||
- 0.0.0.1
|
||||
port_list:
|
||||
- 80
|
||||
- 5432
|
||||
- HTTP
|
||||
- POSTGRES_SERVER
|
||||
protocol_list:
|
||||
- ICMP
|
||||
- TCP
|
||||
@@ -119,14 +119,20 @@ class TestFileSystemRequiresScan:
|
||||
assert obs_not_requiring_scan.observe(file_state)["health_status"] == 3
|
||||
|
||||
def test_folder_require_scan(self):
|
||||
folder_state = {"health_status": 3, "visible_status": 1}
|
||||
folder_state = {"health_status": 3, "visible_status": 1, "scanned_this_step": False}
|
||||
|
||||
obs_requiring_scan = FolderObservation(
|
||||
[], files=[], num_files=0, include_num_access=False, file_system_requires_scan=True
|
||||
)
|
||||
assert obs_requiring_scan.observe(folder_state)["health_status"] == 1
|
||||
assert obs_requiring_scan.observe(folder_state)["health_status"] == 0
|
||||
|
||||
obs_not_requiring_scan = FolderObservation(
|
||||
[], files=[], num_files=0, include_num_access=False, file_system_requires_scan=False
|
||||
)
|
||||
assert obs_not_requiring_scan.observe(folder_state)["health_status"] == 3
|
||||
|
||||
folder_state = {"health_status": 3, "visible_status": 1, "scanned_this_step": True}
|
||||
obs_requiring_scan = FolderObservation(
|
||||
[], files=[], num_files=0, include_num_access=False, file_system_requires_scan=True
|
||||
)
|
||||
assert obs_requiring_scan.observe(folder_state)["health_status"] == 1
|
||||
|
||||
@@ -22,12 +22,12 @@ def test_file_scan(file_system):
|
||||
file: File = file_system.create_file(file_name="test_file.txt", folder_name="test_folder")
|
||||
|
||||
assert file.health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
file.corrupt()
|
||||
|
||||
assert file.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
file.scan()
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ def test_file_scan_request(populated_file_system):
|
||||
|
||||
file.corrupt()
|
||||
assert file.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
fs.apply_request(request=["folder", folder.name, "file", file.name, "scan"])
|
||||
|
||||
@@ -94,7 +94,7 @@ def test_deleted_file_cannot_be_interacted_with(populated_file_system):
|
||||
assert fs.get_file(folder_name=folder.name, file_name=file.name).health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
assert (
|
||||
fs.get_file(folder_name=folder.name, file_name=file.name).visible_health_status
|
||||
== FileSystemItemHealthStatus.GOOD
|
||||
== FileSystemItemHealthStatus.NONE
|
||||
)
|
||||
|
||||
fs.apply_request(request=["delete", "file", folder.name, file.name])
|
||||
|
||||
@@ -44,25 +44,25 @@ def test_folder_scan(file_system):
|
||||
file2: File = folder.get_file_by_id(file_uuid=list(folder.files)[0])
|
||||
|
||||
assert folder.health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file1.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file2.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
assert file1.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
assert file2.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
folder.corrupt()
|
||||
|
||||
assert folder.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file1.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file2.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
assert file1.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
assert file2.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
folder.scan()
|
||||
|
||||
folder.apply_timestep(timestep=0)
|
||||
|
||||
assert folder.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file1.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file2.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
assert file1.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
assert file2.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
folder.apply_timestep(timestep=1)
|
||||
folder.apply_timestep(timestep=2)
|
||||
|
||||
@@ -29,18 +29,18 @@ def test_folder_scan_request(populated_file_system):
|
||||
|
||||
folder.corrupt()
|
||||
assert folder.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file1.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file2.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
assert file1.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
assert file2.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
fs.apply_request(request=["folder", folder.name, "scan"])
|
||||
|
||||
folder.apply_timestep(timestep=0)
|
||||
|
||||
assert folder.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file1.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file2.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
assert file1.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
assert file2.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
folder.apply_timestep(timestep=1)
|
||||
folder.apply_timestep(timestep=2)
|
||||
|
||||
@@ -70,13 +70,13 @@ def test_node_os_scan(node):
|
||||
# add folder and file to node
|
||||
folder: Folder = node.file_system.create_folder(folder_name="test_folder")
|
||||
folder.corrupt()
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
file: File = node.file_system.create_file(folder_name="test_folder", file_name="file.txt")
|
||||
file2: File = node.file_system.create_file(folder_name="test_folder", file_name="file2.txt")
|
||||
file.corrupt()
|
||||
file2.corrupt()
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.GOOD
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
# run os scan
|
||||
node.apply_request(["os", "scan"])
|
||||
|
||||
Reference in New Issue
Block a user