Fix action config schemas and formrequest method for dos bot action
This commit is contained in:
@@ -17,20 +17,20 @@ class NetworkPortAbstractAction(AbstractAction, identifier="network_port_abstrac
|
|||||||
"""Base configuration schema for NetworkPort actions."""
|
"""Base configuration schema for NetworkPort actions."""
|
||||||
|
|
||||||
target_nodename: str
|
target_nodename: str
|
||||||
port_id: int
|
port_num: int
|
||||||
verb: ClassVar[str]
|
verb: ClassVar[str]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def form_request(cls, config: ConfigSchema) -> RequestFormat:
|
def form_request(cls, config: ConfigSchema) -> RequestFormat:
|
||||||
"""Return the action formatted as a request which can be ingested by the PrimAITE simulation."""
|
"""Return the action formatted as a request which can be ingested by the PrimAITE simulation."""
|
||||||
if config.target_nodename is None or config.port_id is None:
|
if config.target_nodename is None or config.port_num is None:
|
||||||
return ["do_nothing"]
|
return ["do_nothing"]
|
||||||
return [
|
return [
|
||||||
"network",
|
"network",
|
||||||
"node",
|
"node",
|
||||||
config.target_nodename,
|
config.target_nodename,
|
||||||
"network_interface",
|
"network_interface",
|
||||||
config.port_id,
|
config.port_num,
|
||||||
config.verb,
|
config.verb,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class ConfigureDoSBotAction(AbstractAction, identifier="configure_dos_bot"):
|
|||||||
max_sessions: Optional[int] = None
|
max_sessions: Optional[int] = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def form_request(config: ConfigSchema) -> RequestFormat:
|
def form_request(cls, config: ConfigSchema) -> RequestFormat:
|
||||||
"""Return the action formatted as a request that can be ingested by the simulation."""
|
"""Return the action formatted as a request that can be ingested by the simulation."""
|
||||||
data = dict(
|
data = dict(
|
||||||
target_ip_address=config.target_ip_address,
|
target_ip_address=config.target_ip_address,
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ def test_c2_server_ransomware(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyA
|
|||||||
"c2_server_ransomware_configure",
|
"c2_server_ransomware_configure",
|
||||||
{
|
{
|
||||||
"node_name": "client_1",
|
"node_name": "client_1",
|
||||||
"config": {"server_ip_address": "10.0.2.3", "payload": "ENCRYPT"},
|
"server_ip_address": "10.0.2.3",
|
||||||
|
"payload": "ENCRYPT",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
agent.store_action(action)
|
agent.store_action(action)
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ def test_network_router_port_disable_integration(game_and_agent: Tuple[PrimaiteG
|
|||||||
"network_port_disable",
|
"network_port_disable",
|
||||||
{
|
{
|
||||||
"target_nodename": "router", # router
|
"target_nodename": "router", # router
|
||||||
"port_id": 1, # port 1
|
"port_num": 2, # port 1
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
agent.store_action(action)
|
agent.store_action(action)
|
||||||
@@ -456,7 +456,7 @@ def test_network_router_port_enable_integration(game_and_agent: Tuple[PrimaiteGa
|
|||||||
"network_port_enable",
|
"network_port_enable",
|
||||||
{
|
{
|
||||||
"target_nodename": "router", # router
|
"target_nodename": "router", # router
|
||||||
"port_id": 1, # port 1
|
"port_num": 2, # port 1
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
agent.store_action(action)
|
agent.store_action(action)
|
||||||
|
|||||||
Reference in New Issue
Block a user