From 89591fd3fbb11f018687e001e40d130280dace50 Mon Sep 17 00:00:00 2001 From: ozgen Date: Fri, 4 Sep 2026 10:12:12 +0200 Subject: [PATCH] add: support agent support bundle encryption Add the optional `encryption` parameter to `get_agent_support_bundle`. Default to encrypted support bundles and allow requesting a plain support bundle by setting `encryption` to `0`. Add tests for the new parameter. --- gvm/protocols/gmp/_gmpnext.py | 3 +++ gvm/protocols/gmp/requests/next/_agents.py | 3 +++ .../agents/test_get_agent_support_bundle.py | 17 ++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/gvm/protocols/gmp/_gmpnext.py b/gvm/protocols/gmp/_gmpnext.py index c67f798f..01ea2e94 100644 --- a/gvm/protocols/gmp/_gmpnext.py +++ b/gvm/protocols/gmp/_gmpnext.py @@ -314,6 +314,7 @@ def get_agent_support_bundle( self, agent_id: EntityID, days: int = 0, + encryption: bool = True, ) -> T: """Request a support bundle for an agent. @@ -321,6 +322,7 @@ def get_agent_support_bundle( agent_id: ID of the agent to get the support bundle for. days: Number of days of logs to include. If None, zero is sent so the Agent Controller uses its configured default. + encryption: Whether an encrypted or plain support bundle is requested. Raises: RequiredArgument: If agent_id is missing. @@ -330,6 +332,7 @@ def get_agent_support_bundle( Agents.get_agent_support_bundle( agent_id, days=days, + encryption=encryption, ) ) diff --git a/gvm/protocols/gmp/requests/next/_agents.py b/gvm/protocols/gmp/requests/next/_agents.py index 361caef6..731c9fd3 100644 --- a/gvm/protocols/gmp/requests/next/_agents.py +++ b/gvm/protocols/gmp/requests/next/_agents.py @@ -438,6 +438,7 @@ def get_agent_support_bundle( agent_id: EntityID, *, days: int = 0, + encryption: bool = True, ) -> Request: """Request a support bundle for an agent. @@ -445,6 +446,7 @@ def get_agent_support_bundle( agent_id: ID of the agent to get the support bundle for. days: Number of days of logs to include. If None, zero is sent so the Agent Controller uses its configured default. + encryption: Whether an encrypted or plain support bundle is requested. Raises: RequiredArgument: If agent_id is missing. @@ -462,5 +464,6 @@ def get_agent_support_bundle( cmd = XmlCommand("get_agent_support_bundle") cmd.set_attribute("agent_uuid", str(agent_id)) cmd.set_attribute("days", str(days)) + cmd.set_attribute("encryption", to_bool(encryption)) return cmd diff --git a/tests/protocols/gmpnext/entities/agents/test_get_agent_support_bundle.py b/tests/protocols/gmpnext/entities/agents/test_get_agent_support_bundle.py index 359a20fc..cf65e67e 100644 --- a/tests/protocols/gmpnext/entities/agents/test_get_agent_support_bundle.py +++ b/tests/protocols/gmpnext/entities/agents/test_get_agent_support_bundle.py @@ -13,7 +13,7 @@ def test_get_agent_support_bundle(self): ) self.connection.send.has_been_called_with( - b'' + b'' ) def test_get_agent_support_bundle_without_days_uses_zero(self): @@ -22,7 +22,7 @@ def test_get_agent_support_bundle_without_days_uses_zero(self): ) self.connection.send.has_been_called_with( - b'' + b'' ) def test_get_agent_support_bundle_with_zero_days(self): @@ -32,7 +32,18 @@ def test_get_agent_support_bundle_with_zero_days(self): ) self.connection.send.has_been_called_with( - b'' + b'' + ) + + def test_get_agent_support_bundle_with_zero_days_false_encryption(self): + self.gmp.get_agent_support_bundle( + agent_id="agent-123", + days=0, + encryption=False, + ) + + self.connection.send.has_been_called_with( + b'' ) def test_get_agent_support_bundle_without_agent_id(self):