From 9d31804c292ea0f98f2c35d454a0d8b722a62cda Mon Sep 17 00:00:00 2001 From: ozgen Date: Fri, 16 Oct 2026 12:59:23 +0200 Subject: [PATCH] add: support anonymization options for agent bundle downloads --- gvm/protocols/gmp/_gmpnext.py | 3 +++ gvm/protocols/gmp/requests/next/_agents.py | 3 +++ .../agents/test_get_agent_support_bundle.py | 22 +++++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/gvm/protocols/gmp/_gmpnext.py b/gvm/protocols/gmp/_gmpnext.py index 77831ea9..8ce40027 100644 --- a/gvm/protocols/gmp/_gmpnext.py +++ b/gvm/protocols/gmp/_gmpnext.py @@ -317,6 +317,7 @@ def get_agent_support_bundle( agent_id: EntityID, days: int = 0, encryption: bool = True, + anonymized: bool = False, ) -> T: """Request a support bundle for an agent. @@ -325,6 +326,7 @@ def get_agent_support_bundle( 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. + anonymized: Whether an anonymized support bundle is requested. Raises: RequiredArgument: If agent_id is missing. @@ -335,6 +337,7 @@ def get_agent_support_bundle( agent_id, days=days, encryption=encryption, + anonymized=anonymized, ) ) diff --git a/gvm/protocols/gmp/requests/next/_agents.py b/gvm/protocols/gmp/requests/next/_agents.py index 731c9fd3..e0571567 100644 --- a/gvm/protocols/gmp/requests/next/_agents.py +++ b/gvm/protocols/gmp/requests/next/_agents.py @@ -439,6 +439,7 @@ def get_agent_support_bundle( *, days: int = 0, encryption: bool = True, + anonymized: bool = False, ) -> Request: """Request a support bundle for an agent. @@ -447,6 +448,7 @@ def get_agent_support_bundle( 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. + anonymized: Whether an anonymized support bundle is requested. Raises: RequiredArgument: If agent_id is missing. @@ -465,5 +467,6 @@ def 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)) + cmd.set_attribute("anonymized", to_bool(anonymized)) 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 cf65e67e..d92086d7 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,7 @@ 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): @@ -43,7 +43,21 @@ def test_get_agent_support_bundle_with_zero_days_false_encryption(self): ) self.connection.send.has_been_called_with( - b'' + b'' + ) + + def test_get_agent_support_bundle_with_zero_days_false_encryption_true_anonymized( + self, + ): + self.gmp.get_agent_support_bundle( + agent_id="agent-123", + days=0, + encryption=False, + anonymized=True, + ) + + self.connection.send.has_been_called_with( + b'' ) def test_get_agent_support_bundle_without_agent_id(self):