Merged PR 363: Make ftp client only default on computers, not servers
## Summary REMOVE ftp client from host node default software and add it to computer default software, effectively removing it from servers. Ensure tests are using the uc2 yaml file instead of outdated network generator function. Fix some tests to make sure it all passing ## Test process I have tested it. ## Checklist - [X] PR is linked to a **work item** - [X] **acceptance criteria** of linked ticket are met - [X] performed **self-review** of the code - [X] written **tests** for any new functionality added with this PR - [ ] updated the **documentation** if this PR changes or adds functionality - [ ] written/updated **design docs** if this PR implements new functionality - [ ] updated the **change log** - [X] ran **pre-commit** checks for code style - [X] attended to any **TO-DOs** left in the code Make ftp client only default on computers, not servers Related work items: #2546
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
from typing import ClassVar, Dict
|
||||
|
||||
from primaite.simulator.network.hardware.nodes.host.host_node import HostNode
|
||||
from primaite.simulator.system.services.ftp.ftp_client import FTPClient
|
||||
|
||||
|
||||
class Computer(HostNode):
|
||||
@@ -29,4 +32,6 @@ class Computer(HostNode):
|
||||
* Web Browser
|
||||
"""
|
||||
|
||||
SYSTEM_SOFTWARE: ClassVar[Dict] = {**HostNode.SYSTEM_SOFTWARE, "FTPClient": FTPClient}
|
||||
|
||||
pass
|
||||
|
||||
@@ -10,7 +10,6 @@ from primaite.simulator.network.transmission.data_link_layer import Frame
|
||||
from primaite.simulator.system.applications.web_browser import WebBrowser
|
||||
from primaite.simulator.system.services.arp.arp import ARP, ARPPacket
|
||||
from primaite.simulator.system.services.dns.dns_client import DNSClient
|
||||
from primaite.simulator.system.services.ftp.ftp_client import FTPClient
|
||||
from primaite.simulator.system.services.icmp.icmp import ICMP
|
||||
from primaite.simulator.system.services.ntp.ntp_client import NTPClient
|
||||
from primaite.utils.validators import IPV4Address
|
||||
@@ -301,7 +300,6 @@ class HostNode(Node):
|
||||
"HostARP": HostARP,
|
||||
"ICMP": ICMP,
|
||||
"DNSClient": DNSClient,
|
||||
"FTPClient": FTPClient,
|
||||
"NTPClient": NTPClient,
|
||||
"WebBrowser": WebBrowser,
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
from typing import Any, Dict, Tuple
|
||||
|
||||
import pytest
|
||||
import yaml
|
||||
|
||||
from primaite import getLogger
|
||||
from primaite import getLogger, PRIMAITE_PATHS
|
||||
from primaite.game.agent.actions import ActionManager
|
||||
from primaite.game.agent.interface import AbstractAgent
|
||||
from primaite.game.agent.observations.observation_manager import NestedObservation, ObservationManager
|
||||
@@ -65,7 +66,10 @@ class TestApplication(Application):
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def uc2_network() -> Network:
|
||||
return arcd_uc2_network()
|
||||
with open(PRIMAITE_PATHS.user_config_path / "example_config" / "data_manipulation.yaml") as f:
|
||||
cfg = yaml.safe_load(f)
|
||||
game = PrimaiteGame.from_config(cfg)
|
||||
return game.simulation.network
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
|
||||
@@ -26,6 +26,9 @@ def test_data_manipulation(uc2_network):
|
||||
# First check that the DB client on the web_server can successfully query the users table on the database
|
||||
assert db_connection.query("SELECT")
|
||||
|
||||
db_manipulation_bot.data_manipulation_p_of_success = 1.0
|
||||
db_manipulation_bot.port_scan_p_of_success = 1.0
|
||||
|
||||
# Now we run the DataManipulationBot
|
||||
db_manipulation_bot.attack()
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ def test_sometech_webserver_cannot_access_ftp_on_sometech_storage_server():
|
||||
some_tech_storage_srv.file_system.create_file(file_name="test.png")
|
||||
|
||||
web_server: Server = network.get_node_by_hostname("some_tech_web_srv")
|
||||
|
||||
web_server.software_manager.install(FTPClient)
|
||||
web_ftp_client: FTPClient = web_server.software_manager.software["FTPClient"]
|
||||
|
||||
assert not web_ftp_client.request_file(
|
||||
|
||||
@@ -101,7 +101,7 @@ def test_database_client_native_connection_query(uc2_network):
|
||||
"""Tests DB query across the network returns HTTP status 200 and date."""
|
||||
web_server: Server = uc2_network.get_node_by_hostname("web_server")
|
||||
db_client: DatabaseClient = web_server.software_manager.software["DatabaseClient"]
|
||||
|
||||
db_client.connect()
|
||||
assert db_client.query(sql="SELECT")
|
||||
assert db_client.query(sql="INSERT")
|
||||
|
||||
@@ -222,6 +222,7 @@ def test_database_client_cannot_query_offline_database_server(uc2_network):
|
||||
|
||||
web_server: Server = uc2_network.get_node_by_hostname("web_server")
|
||||
db_client: DatabaseClient = web_server.software_manager.software.get("DatabaseClient")
|
||||
db_client.connect()
|
||||
assert len(db_client.client_connections)
|
||||
|
||||
# Establish a new connection to the DatabaseService
|
||||
|
||||
Reference in New Issue
Block a user