diff --git a/gvm/protocols/gmp/_gmpnext.py b/gvm/protocols/gmp/_gmpnext.py index 88f7ecf7..661ed246 100644 --- a/gvm/protocols/gmp/_gmpnext.py +++ b/gvm/protocols/gmp/_gmpnext.py @@ -117,6 +117,7 @@ def modify_agents( agent_ids: list[EntityID], *, authorized: Optional[bool] = None, + update_to_latest: Optional[bool] = None, config: Optional[Mapping[str, Any]] = None, comment: Optional[str] = None, ) -> T: @@ -126,6 +127,7 @@ def modify_agents( Args: agent_ids: List of agent UUIDs to modify. authorized: Whether the agent is authorized. + update_to_latest: Whether the agent is allowed to update to latest automatically. config: Nested config for Agent Controller. comment: Optional comment for the change. """ @@ -133,6 +135,7 @@ def modify_agents( Agents.modify_agents( agent_ids=agent_ids, authorized=authorized, + update_to_latest=update_to_latest, config=config, comment=comment, ) diff --git a/gvm/protocols/gmp/requests/next/_agents.py b/gvm/protocols/gmp/requests/next/_agents.py index 816d46b7..a14e1b81 100644 --- a/gvm/protocols/gmp/requests/next/_agents.py +++ b/gvm/protocols/gmp/requests/next/_agents.py @@ -188,6 +188,7 @@ def modify_agents( agent_ids: list[EntityID], *, authorized: Optional[bool] = None, + update_to_latest: Optional[bool] = None, config: Optional[Mapping[str, Any]] = None, comment: Optional[str] = None, ) -> Request: @@ -197,6 +198,7 @@ def modify_agents( Args: agent_ids: List of agent UUIDs to modify. authorized: Whether the agent is authorized. + update_to_latest: Whether the agent is allowed to update to latest automatically. config: Nested config, e.g.: { "agent_control": { @@ -233,6 +235,9 @@ def modify_agents( if authorized is not None: cmd.add_element("authorized", to_bool(authorized)) + if update_to_latest is not None: + cmd.add_element("update_to_latest", to_bool(update_to_latest)) + if config is not None: cls._validate_agent_config( config, caller=cls.modify_agents.__name__ diff --git a/tests/protocols/gmpnext/entities/agents/test_modify_agents.py b/tests/protocols/gmpnext/entities/agents/test_modify_agents.py index 290b78b0..cb021350 100644 --- a/tests/protocols/gmpnext/entities/agents/test_modify_agents.py +++ b/tests/protocols/gmpnext/entities/agents/test_modify_agents.py @@ -27,6 +27,18 @@ def test_modify_agents_with_authorized_only(self): b"" ) + def test_modify_agents_with_update_to_latest_only(self): + self.gmp.modify_agents( + agent_ids=["agent-123", "agent-456"], update_to_latest=True + ) + + self.connection.send.has_been_called_with( + b"" + b'' + b"1" + b"" + ) + def test_modify_agents_with_full_config_and_comment(self): cfg = { "agent_control": { @@ -48,6 +60,7 @@ def test_modify_agents_with_full_config_and_comment(self): self.gmp.modify_agents( agent_ids=["agent-123", "agent-456"], authorized=True, + update_to_latest=True, config=cfg, comment="Updated agents", ) @@ -56,6 +69,7 @@ def test_modify_agents_with_full_config_and_comment(self): b"" b'' b"1" + b"1" b"" b"" b""