Apply suggestions from PR review.

This commit is contained in:
Marek Wolan
2024-03-04 09:58:57 +00:00
parent a6031d568d
commit d1480e4477
16 changed files with 25 additions and 19 deletions

View File

@@ -19,7 +19,7 @@ Agents can be scripted (deterministic and stochastic), or controlled by a reinfo
... ...
- ref: green_agent_example - ref: green_agent_example
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
observation_space: observation_space:
type: UC2GreenObservation type: UC2GreenObservation
action_space: action_space:
@@ -57,11 +57,11 @@ Specifies if the agent is malicious (``RED``), benign (``GREEN``), or defensive
``type`` ``type``
-------- --------
Specifies which class should be used for the agent. ``ProxyAgent`` is used for agents that receive instructions from an RL algorithm. Scripted agents like ``RedDatabaseCorruptingAgent`` and ``probabilistic_agent`` generate their own behaviour. Specifies which class should be used for the agent. ``ProxyAgent`` is used for agents that receive instructions from an RL algorithm. Scripted agents like ``RedDatabaseCorruptingAgent`` and ``ProbabilisticAgent`` generate their own behaviour.
Available agent types: Available agent types:
- ``probabilistic_agent`` - ``ProbabilisticAgent``
- ``ProxyAgent`` - ``ProxyAgent``
- ``RedDatabaseCorruptingAgent`` - ``RedDatabaseCorruptingAgent``

View File

@@ -25,6 +25,13 @@ Usage
- Clients connect, execute queries, and disconnect. - Clients connect, execute queries, and disconnect.
- Service runs on TCP port 5432 by default. - Service runs on TCP port 5432 by default.
**Supported queries:**
* ``SELECT``: As long as the database file is in a ``GOOD`` health state, the db service will respond with a 200 status code.
* ``DELETE``: This query represents an attack, it will cause the database file to enter a ``COMPROMISED`` state, and return a status code 200.
* ``INSERT``: If the database service is in a healthy state, this will return a 200 status, if it's not in a healthy state it will return 404.
* ``SELECT * FROM pg_stat_activity``: This query represents something an admin would send to check the status of the database. If the database service is in a healthy state, it returns a 200 status code, otherwise a 401 status code.
Implementation Implementation
============== ==============

View File

@@ -33,7 +33,7 @@ game:
agents: agents:
- ref: client_2_green_user - ref: client_2_green_user
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
agent_settings: agent_settings:
action_probabilities: action_probabilities:
0: 0.3 0: 0.3
@@ -76,7 +76,7 @@ agents:
- ref: client_1_green_user - ref: client_1_green_user
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
agent_settings: agent_settings:
action_probabilities: action_probabilities:
0: 0.3 0: 0.3

View File

@@ -35,7 +35,7 @@ game:
agents: agents:
- ref: client_2_green_user - ref: client_2_green_user
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
observation_space: observation_space:
type: UC2GreenObservation type: UC2GreenObservation
action_space: action_space:
@@ -64,7 +64,7 @@ agents:
- ref: client_1_green_user - ref: client_1_green_user
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
observation_space: observation_space:
type: UC2GreenObservation type: UC2GreenObservation
action_space: action_space:

View File

@@ -414,7 +414,7 @@ class PrimaiteGame:
reward_function = RewardFunction.from_config(reward_function_cfg) reward_function = RewardFunction.from_config(reward_function_cfg)
# CREATE AGENT # CREATE AGENT
if agent_type == "probabilistic_agent": if agent_type == "ProbabilisticAgent":
# TODO: implement non-random agents and fix this parsing # TODO: implement non-random agents and fix this parsing
settings = agent_cfg.get("agent_settings") settings = agent_cfg.get("agent_settings")
new_agent = ProbabilisticAgent( new_agent = ProbabilisticAgent(

View File

@@ -16,7 +16,7 @@ class IPProtocol(Enum):
""" """
NONE = "none" NONE = "none"
"""Placeholder for a non-port.""" """Placeholder for a non-protocol."""
TCP = "tcp" TCP = "tcp"
"""Transmission Control Protocol.""" """Transmission Control Protocol."""
UDP = "udp" UDP = "udp"

View File

@@ -38,9 +38,7 @@ class DataManipulationAttackStage(IntEnum):
class DataManipulationBot(Application): class DataManipulationBot(Application):
"""A bot that simulates a script which performs a SQL injection attack.""" """A bot that simulates a script which performs a SQL injection attack."""
# server_ip_address: Optional[IPv4Address] = None
payload: Optional[str] = None payload: Optional[str] = None
# server_password: Optional[str] = None
port_scan_p_of_success: float = 0.1 port_scan_p_of_success: float = 0.1
data_manipulation_p_of_success: float = 0.1 data_manipulation_p_of_success: float = 0.1

View File

@@ -21,7 +21,7 @@ game:
agents: agents:
- ref: client_2_green_user - ref: client_2_green_user
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
observation_space: observation_space:
type: UC2GreenObservation type: UC2GreenObservation
action_space: action_space:

View File

@@ -40,7 +40,7 @@ game:
agents: agents:
- ref: client_2_green_user - ref: client_2_green_user
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
observation_space: observation_space:
type: UC2GreenObservation type: UC2GreenObservation
action_space: action_space:

View File

@@ -40,7 +40,7 @@ game:
agents: agents:
- ref: client_2_green_user - ref: client_2_green_user
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
observation_space: observation_space:
type: UC2GreenObservation type: UC2GreenObservation
action_space: action_space:

View File

@@ -65,7 +65,7 @@ game:
agents: agents:
- ref: client_1_green_user - ref: client_1_green_user
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
observation_space: observation_space:
type: UC2GreenObservation type: UC2GreenObservation
action_space: action_space:

View File

@@ -25,7 +25,7 @@ game:
agents: agents:
- ref: client_2_green_user - ref: client_2_green_user
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
observation_space: observation_space:
type: UC2GreenObservation type: UC2GreenObservation
action_space: action_space:

View File

@@ -31,7 +31,7 @@ game:
agents: agents:
- ref: client_2_green_user - ref: client_2_green_user
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
observation_space: observation_space:
type: UC2GreenObservation type: UC2GreenObservation
action_space: action_space:

View File

@@ -29,7 +29,7 @@ game:
agents: agents:
- ref: client_2_green_user - ref: client_2_green_user
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
observation_space: observation_space:
type: UC2GreenObservation type: UC2GreenObservation
action_space: action_space:

View File

@@ -25,7 +25,7 @@ game:
agents: agents:
- ref: client_2_green_user - ref: client_2_green_user
team: GREEN team: GREEN
type: probabilistic_agent type: ProbabilisticAgent
observation_space: observation_space:
type: UC2GreenObservation type: UC2GreenObservation
action_space: action_space:

View File

@@ -41,6 +41,7 @@ def test_WebpageUnavailablePenalty(game_and_agent):
def test_uc2_rewards(game_and_agent): def test_uc2_rewards(game_and_agent):
"""Test that the reward component correctly applies a penalty when the selected client cannot reach the database."""
game, agent = game_and_agent game, agent = game_and_agent
agent: ControlledAgent agent: ControlledAgent