#3062 - First pass at unifying naming convention for discriminators (still errors) [skip ci]
This commit is contained in:
@@ -35,7 +35,7 @@ def test_do_nothing_integration(game_and_agent: Tuple[PrimaiteGame, ProxyAgent])
|
||||
"""Test that the do_nothingAction can form a request and that it is accepted by the simulation."""
|
||||
game, agent = game_and_agent
|
||||
|
||||
action = ("do_nothing", {})
|
||||
action = ("do-nothing", {})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
@@ -51,12 +51,12 @@ def test_node_service_scan_integration(game_and_agent: Tuple[PrimaiteGame, Proxy
|
||||
game, agent = game_and_agent
|
||||
|
||||
# 1: Check that the service starts off in a good state, and that visible state is hidden until first scan
|
||||
svc = game.simulation.network.get_node_by_hostname("server_1").software_manager.software.get("DNSServer")
|
||||
svc = game.simulation.network.get_node_by_hostname("server_1").software_manager.software.get("dns-server")
|
||||
assert svc.health_state_actual == SoftwareHealthState.GOOD
|
||||
assert svc.health_state_visible == SoftwareHealthState.UNUSED
|
||||
|
||||
# 2: Scan and check that the visible state is now correct
|
||||
action = ("node_service_scan", {"node_name": "server_1", "service_name": "DNSServer"})
|
||||
action = ("node-service-scan", {"node_name": "server_1", "service_name": "dns-server"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert svc.health_state_actual == SoftwareHealthState.GOOD
|
||||
@@ -67,7 +67,7 @@ def test_node_service_scan_integration(game_and_agent: Tuple[PrimaiteGame, Proxy
|
||||
assert svc.health_state_visible == SoftwareHealthState.GOOD
|
||||
|
||||
# 4: Scan and check that the visible state is now correct
|
||||
action = ("node_service_scan", {"node_name": "server_1", "service_name": "DNSServer"})
|
||||
action = ("node-service-scan", {"node_name": "server_1", "service_name": "dns-server"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert svc.health_state_actual == SoftwareHealthState.COMPROMISED
|
||||
@@ -84,11 +84,11 @@ def test_node_service_fix_integration(game_and_agent: Tuple[PrimaiteGame, ProxyA
|
||||
game, agent = game_and_agent
|
||||
|
||||
# 1: Corrupt the service
|
||||
svc = game.simulation.network.get_node_by_hostname("server_1").software_manager.software.get("DNSServer")
|
||||
svc = game.simulation.network.get_node_by_hostname("server_1").software_manager.software.get("dns-server")
|
||||
svc.health_state_actual = SoftwareHealthState.COMPROMISED
|
||||
|
||||
# 2: Apply a patch action
|
||||
action = ("node_service_fix", {"node_name": "server_1", "service_name": "DNSServer"})
|
||||
action = ("node-service-fix", {"node_name": "server_1", "service_name": "dns-server"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
@@ -96,7 +96,7 @@ def test_node_service_fix_integration(game_and_agent: Tuple[PrimaiteGame, ProxyA
|
||||
assert svc.health_state_actual == SoftwareHealthState.FIXING
|
||||
|
||||
# 4: perform a few do-nothing steps and check that the service is now in the good state
|
||||
action = ("do_nothing", {})
|
||||
action = ("do-nothing", {})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert svc.health_state_actual == SoftwareHealthState.GOOD
|
||||
@@ -106,7 +106,7 @@ def test_router_acl_addrule_integration(game_and_agent: Tuple[PrimaiteGame, Prox
|
||||
"""
|
||||
Test that the RouterACLAddRuleAction can form a request and that it is accepted by the simulation.
|
||||
|
||||
The ACL starts off with 4 rules, and we add a rule, and check that the ACL now has 5 rules.
|
||||
The acl starts off with 4 rules, and we add a rule, and check that the acl now has 5 rules.
|
||||
"""
|
||||
game, agent = game_and_agent
|
||||
|
||||
@@ -121,7 +121,7 @@ def test_router_acl_addrule_integration(game_and_agent: Tuple[PrimaiteGame, Prox
|
||||
|
||||
# 2: Add a rule to block client 1 from reaching server 2 on router
|
||||
action = (
|
||||
"router_acl_add_rule",
|
||||
"router-acl-add-rule",
|
||||
{
|
||||
"target_router": "router",
|
||||
"position": 4,
|
||||
@@ -138,7 +138,7 @@ def test_router_acl_addrule_integration(game_and_agent: Tuple[PrimaiteGame, Prox
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
# 3: Check that the ACL now has 5 rules, and that client 1 cannot ping server 2
|
||||
# 3: Check that the acl now has 5 rules, and that client 1 cannot ping server 2
|
||||
assert router.acl.num_rules == 5
|
||||
assert not client_1.ping("10.0.2.3") # Cannot ping server_2
|
||||
assert client_1.ping("10.0.2.2") # Can ping server_1
|
||||
@@ -148,7 +148,7 @@ def test_router_acl_addrule_integration(game_and_agent: Tuple[PrimaiteGame, Prox
|
||||
|
||||
# 4: Add a rule to block server_1 from reaching server_2 on router (this should not affect comms as they are on same subnet)
|
||||
action = (
|
||||
"router_acl_add_rule",
|
||||
"router-acl-add-rule",
|
||||
{
|
||||
"target_router": "router",
|
||||
"position": 5, # 5th rule
|
||||
@@ -181,14 +181,14 @@ def test_router_acl_removerule_integration(game_and_agent: Tuple[PrimaiteGame, P
|
||||
server_1 = game.simulation.network.get_node_by_hostname("server_1")
|
||||
router = game.simulation.network.get_node_by_hostname("router")
|
||||
|
||||
browser: WebBrowser = client_1.software_manager.software.get("WebBrowser")
|
||||
browser: WebBrowser = client_1.software_manager.software.get("web-browser")
|
||||
browser.run()
|
||||
browser.config.target_url = "http://www.example.com"
|
||||
assert browser.get_webpage() # check that the browser can access example.com before we block it
|
||||
|
||||
# 2: Remove rule that allows HTTP traffic across the network
|
||||
action = (
|
||||
"router_acl_remove_rule",
|
||||
"router-acl-remove-rule",
|
||||
{
|
||||
"target_router": "router",
|
||||
"position": 3, # 4th rule
|
||||
@@ -200,7 +200,7 @@ def test_router_acl_removerule_integration(game_and_agent: Tuple[PrimaiteGame, P
|
||||
# 3: Check that the ACL now has 3 rules, and that client 1 cannot access example.com
|
||||
assert router.acl.num_rules == 3
|
||||
assert not browser.get_webpage()
|
||||
client_1.software_manager.software.get("DNSClient").dns_cache.clear()
|
||||
client_1.software_manager.software.get("dns-client").dns_cache.clear()
|
||||
assert client_1.ping("10.0.2.2") # pinging still works because ICMP is allowed
|
||||
assert client_1.ping("10.0.2.3")
|
||||
|
||||
@@ -214,14 +214,14 @@ def test_host_nic_disable_integration(game_and_agent: Tuple[PrimaiteGame, ProxyA
|
||||
server_1 = game.simulation.network.get_node_by_hostname("server_1")
|
||||
server_2 = game.simulation.network.get_node_by_hostname("server_2")
|
||||
|
||||
browser: WebBrowser = client_1.software_manager.software.get("WebBrowser")
|
||||
browser: WebBrowser = client_1.software_manager.software.get("web-browser")
|
||||
browser.run()
|
||||
browser.config.target_url = "http://www.example.com"
|
||||
assert browser.get_webpage() # check that the browser can access example.com before we block it
|
||||
|
||||
# 2: Disable the NIC on client_1
|
||||
action = (
|
||||
"host_nic_disable",
|
||||
"host-nic-disable",
|
||||
{
|
||||
"node_name": "client_1", # client_1
|
||||
"nic_num": 1, # the only nic (eth-1)
|
||||
@@ -252,7 +252,7 @@ def test_host_nic_enable_integration(game_and_agent: Tuple[PrimaiteGame, ProxyAg
|
||||
|
||||
# 2: Use action to enable nic
|
||||
action = (
|
||||
"host_nic_enable",
|
||||
"host-nic-enable",
|
||||
{
|
||||
"node_name": "client_1", # client_1
|
||||
"nic_num": 1, # the only nic (eth-1)
|
||||
@@ -279,7 +279,7 @@ def test_node_file_scan_integration(game_and_agent: Tuple[PrimaiteGame, ProxyAge
|
||||
|
||||
# 2: perform a scan and make sure nothing has changed
|
||||
action = (
|
||||
"node_file_scan",
|
||||
"node-file-scan",
|
||||
{
|
||||
"node_name": "client_1", # client_1,
|
||||
"folder_name": "downloads", # downloads,
|
||||
@@ -316,7 +316,7 @@ def test_node_file_delete_integration(game_and_agent: Tuple[PrimaiteGame, ProxyA
|
||||
|
||||
# 2: delete the file
|
||||
action = (
|
||||
"node_file_delete",
|
||||
"node-file-delete",
|
||||
{
|
||||
"node_name": "client_1", # client_1
|
||||
"folder_name": "downloads", # downloads
|
||||
@@ -339,7 +339,7 @@ def test_node_file_create(game_and_agent: Tuple[PrimaiteGame, ProxyAgent]):
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
|
||||
action = (
|
||||
"node_file_create",
|
||||
"node-file-create",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"folder_name": "test",
|
||||
@@ -360,7 +360,7 @@ def test_node_file_access(game_and_agent: Tuple[PrimaiteGame, ProxyAgent]):
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1") #
|
||||
|
||||
action = (
|
||||
"node_file_create",
|
||||
"node-file-create",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"folder_name": "test",
|
||||
@@ -373,7 +373,7 @@ def test_node_file_access(game_and_agent: Tuple[PrimaiteGame, ProxyAgent]):
|
||||
assert client_1.file_system.get_file(folder_name="test", file_name="file.txt").num_access == 0
|
||||
|
||||
action = (
|
||||
"node_file_access",
|
||||
"node-file-access",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"folder_name": "test",
|
||||
@@ -393,7 +393,7 @@ def test_node_folder_create(game_and_agent: Tuple[PrimaiteGame, ProxyAgent]):
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1") #
|
||||
|
||||
action = (
|
||||
"node_folder_create",
|
||||
"node-folder-create",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"folder_name": "test",
|
||||
@@ -414,14 +414,14 @@ def test_network_router_port_disable_integration(game_and_agent: Tuple[PrimaiteG
|
||||
server_1 = game.simulation.network.get_node_by_hostname("server_1")
|
||||
router = game.simulation.network.get_node_by_hostname("router")
|
||||
|
||||
browser: WebBrowser = client_1.software_manager.software.get("WebBrowser")
|
||||
browser: WebBrowser = client_1.software_manager.software.get("web-browser")
|
||||
browser.run()
|
||||
browser.config.target_url = "http://www.example.com"
|
||||
assert browser.get_webpage() # check that the browser can access example.com before we block it
|
||||
|
||||
# 2: Disable the NIC on client_1
|
||||
action = (
|
||||
"network_port_disable",
|
||||
"network-port-disable",
|
||||
{
|
||||
"target_nodename": "router", # router
|
||||
"port_num": 1, # port 1
|
||||
@@ -453,7 +453,7 @@ def test_network_router_port_enable_integration(game_and_agent: Tuple[PrimaiteGa
|
||||
|
||||
# 2: Use action to enable port
|
||||
action = (
|
||||
"network_port_enable",
|
||||
"network-port-enable",
|
||||
{
|
||||
"target_nodename": "router", # router
|
||||
"port_num": 1, # port 1
|
||||
@@ -474,7 +474,7 @@ def test_node_application_scan_integration(game_and_agent: Tuple[PrimaiteGame, P
|
||||
# 1: Check that http traffic is going across the network nicely.
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
|
||||
browser: WebBrowser = client_1.software_manager.software.get("WebBrowser")
|
||||
browser: WebBrowser = client_1.software_manager.software.get("web-browser")
|
||||
browser.run()
|
||||
browser.config.target_url = "http://www.example.com"
|
||||
assert browser.get_webpage() # check that the browser can access example.com
|
||||
@@ -484,8 +484,8 @@ def test_node_application_scan_integration(game_and_agent: Tuple[PrimaiteGame, P
|
||||
|
||||
# 2: Scan and check that the visible state is now correct
|
||||
action = (
|
||||
"node_application_scan",
|
||||
{"node_name": "client_1", "application_name": "WebBrowser"},
|
||||
"node-application-scan",
|
||||
{"node_name": "client_1", "application_name": "web-browser"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
@@ -498,8 +498,8 @@ def test_node_application_scan_integration(game_and_agent: Tuple[PrimaiteGame, P
|
||||
|
||||
# 4: Scan and check that the visible state is now correct
|
||||
action = (
|
||||
"node_application_scan",
|
||||
{"node_name": "client_1", "application_name": "WebBrowser"},
|
||||
"node-application-scan",
|
||||
{"node_name": "client_1", "application_name": "web-browser"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
@@ -517,13 +517,13 @@ def test_node_application_fix_integration(game_and_agent: Tuple[PrimaiteGame, Pr
|
||||
# 1: Check that http traffic is going across the network nicely.
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
|
||||
browser: WebBrowser = client_1.software_manager.software.get("WebBrowser")
|
||||
browser: WebBrowser = client_1.software_manager.software.get("web-browser")
|
||||
browser.health_state_actual = SoftwareHealthState.COMPROMISED
|
||||
|
||||
# 2: Apply a fix action
|
||||
action = (
|
||||
"node_application_fix",
|
||||
{"node_name": "client_1", "application_name": "WebBrowser"},
|
||||
"node-application-fix",
|
||||
{"node_name": "client_1", "application_name": "web-browser"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
@@ -532,7 +532,7 @@ def test_node_application_fix_integration(game_and_agent: Tuple[PrimaiteGame, Pr
|
||||
assert browser.health_state_actual == SoftwareHealthState.FIXING
|
||||
|
||||
# 4: perform a few do-nothing steps and check that the application is now in the good state
|
||||
action = ("do_nothing", {})
|
||||
action = ("do-nothing", {})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert browser.health_state_actual == SoftwareHealthState.GOOD
|
||||
@@ -545,14 +545,14 @@ def test_node_application_close_integration(game_and_agent: Tuple[PrimaiteGame,
|
||||
game, agent = game_and_agent
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
|
||||
browser: WebBrowser = client_1.software_manager.software.get("WebBrowser")
|
||||
browser: WebBrowser = client_1.software_manager.software.get("web-browser")
|
||||
browser.run()
|
||||
assert browser.operating_state == ApplicationOperatingState.RUNNING
|
||||
|
||||
# 2: Apply a close action
|
||||
action = (
|
||||
"node_application_close",
|
||||
{"node_name": "client_1", "application_name": "WebBrowser"},
|
||||
"node-application-close",
|
||||
{"node_name": "client_1", "application_name": "web-browser"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
@@ -570,25 +570,25 @@ def test_node_application_install_and_uninstall_integration(game_and_agent: Tupl
|
||||
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
|
||||
assert client_1.software_manager.software.get("DoSBot") is None
|
||||
assert client_1.software_manager.software.get("dos-bot") is None
|
||||
|
||||
action = (
|
||||
"node_application_install",
|
||||
{"node_name": "client_1", "application_name": "DoSBot"},
|
||||
"node-application-install",
|
||||
{"node_name": "client_1", "application_name": "dos-bot"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
assert client_1.software_manager.software.get("DoSBot") is not None
|
||||
assert client_1.software_manager.software.get("dos-bot") is not None
|
||||
|
||||
action = (
|
||||
"node_application_remove",
|
||||
{"node_name": "client_1", "application_name": "DoSBot"},
|
||||
"node-application-remove",
|
||||
{"node_name": "client_1", "application_name": "dos-bot"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
assert client_1.software_manager.software.get("DoSBot") is None
|
||||
assert client_1.software_manager.software.get("dos-bot") is None
|
||||
|
||||
|
||||
def test_firewall_acl_add_remove_rule_integration():
|
||||
|
||||
Reference in New Issue
Block a user