From 386717fa4166d935e09524681905b285d56e3223 Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Mon, 9 Dec 2024 09:59:47 +0000 Subject: [PATCH] #2912 - removal of the rom_config method as this shouldn't be needed for the actions refactor --- src/primaite/game/agent/actions/abstract.py | 5 ----- src/primaite/game/agent/actions/acl.py | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/primaite/game/agent/actions/abstract.py b/src/primaite/game/agent/actions/abstract.py index ef22ec54..8c332d5e 100644 --- a/src/primaite/game/agent/actions/abstract.py +++ b/src/primaite/game/agent/actions/abstract.py @@ -32,8 +32,3 @@ class AbstractAction(BaseModel): def form_request(cls, config: ConfigSchema) -> RequestFormat: """Return the action formatted as a request which can be ingested by the PrimAITE simulation.""" pass - - @classmethod - def from_config(cls, config: Dict) -> "AbstractAction": - """Create an action component from a config dictionary.""" - return cls(config=cls.ConfigSchema(**config)) diff --git a/src/primaite/game/agent/actions/acl.py b/src/primaite/game/agent/actions/acl.py index f129a82f..5cd7a355 100644 --- a/src/primaite/game/agent/actions/acl.py +++ b/src/primaite/game/agent/actions/acl.py @@ -79,6 +79,24 @@ class ACLRemoveRuleAbstractAction(AbstractAction, identifier="acl_remove_rule_ab protocol_name: str position: int + @field_validator( + src_ip, + mode="before", + ) + @classmethod + def valid_ip(cls, v: str) -> str: + """Check that a valid IP has been provided for src and dst.""" + return is_valid_protocol(v) + + @field_validator( + protocol_name, + mode="before", + ) + @classmethod + def is_valid_protocol(cls, v: str) -> bool: + """Check that we are using a valid protocol.""" + return protocol_validator(v) + class RouterACLAddRuleAction(ACLAddRuleAbstractAction, identifier="router_acl_add_rule"): """Action which adds a rule to a router's ACL."""