Skip to content

Commit 89591fd

Browse files
committed
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.
1 parent 2b42a13 commit 89591fd

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎gvm/protocols/gmp/_gmpnext.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,15 @@ def get_agent_support_bundle(
314314
self,
315315
agent_id: EntityID,
316316
days: int = 0,
317+
encryption: bool = True,
317318
) -> T:
318319
"""Request a support bundle for an agent.
319320
320321
Args:
321322
agent_id: ID of the agent to get the support bundle for.
322323
days: Number of days of logs to include. If None, zero is sent so the
323324
Agent Controller uses its configured default.
325+
encryption: Whether an encrypted or plain support bundle is requested.
324326
325327
Raises:
326328
RequiredArgument: If agent_id is missing.
@@ -330,6 +332,7 @@ def get_agent_support_bundle(
330332
Agents.get_agent_support_bundle(
331333
agent_id,
332334
days=days,
335+
encryption=encryption,
333336
)
334337
)
335338

‎gvm/protocols/gmp/requests/next/_agents.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,15 @@ def get_agent_support_bundle(
438438
agent_id: EntityID,
439439
*,
440440
days: int = 0,
441+
encryption: bool = True,
441442
) -> Request:
442443
"""Request a support bundle for an agent.
443444
444445
Args:
445446
agent_id: ID of the agent to get the support bundle for.
446447
days: Number of days of logs to include. If None, zero is sent so the
447448
Agent Controller uses its configured default.
449+
encryption: Whether an encrypted or plain support bundle is requested.
448450
449451
Raises:
450452
RequiredArgument: If agent_id is missing.
@@ -462,5 +464,6 @@ def get_agent_support_bundle(
462464
cmd = XmlCommand("get_agent_support_bundle")
463465
cmd.set_attribute("agent_uuid", str(agent_id))
464466
cmd.set_attribute("days", str(days))
467+
cmd.set_attribute("encryption", to_bool(encryption))
465468

466469
return cmd

‎tests/protocols/gmpnext/entities/agents/test_get_agent_support_bundle.py‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_get_agent_support_bundle(self):
1313
)
1414

1515
self.connection.send.has_been_called_with(
16-
b'<get_agent_support_bundle agent_uuid="agent-123" days="7"/>'
16+
b'<get_agent_support_bundle agent_uuid="agent-123" days="7" encryption="1"/>'
1717
)
1818

1919
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):
2222
)
2323

2424
self.connection.send.has_been_called_with(
25-
b'<get_agent_support_bundle agent_uuid="agent-123" days="0"/>'
25+
b'<get_agent_support_bundle agent_uuid="agent-123" days="0" encryption="1"/>'
2626
)
2727

2828
def test_get_agent_support_bundle_with_zero_days(self):
@@ -32,7 +32,18 @@ def test_get_agent_support_bundle_with_zero_days(self):
3232
)
3333

3434
self.connection.send.has_been_called_with(
35-
b'<get_agent_support_bundle agent_uuid="agent-123" days="0"/>'
35+
b'<get_agent_support_bundle agent_uuid="agent-123" days="0" encryption="1"/>'
36+
)
37+
38+
def test_get_agent_support_bundle_with_zero_days_false_encryption(self):
39+
self.gmp.get_agent_support_bundle(
40+
agent_id="agent-123",
41+
days=0,
42+
encryption=False,
43+
)
44+
45+
self.connection.send.has_been_called_with(
46+
b'<get_agent_support_bundle agent_uuid="agent-123" days="0" encryption="0"/>'
3647
)
3748

3849
def test_get_agent_support_bundle_without_agent_id(self):

0 commit comments

Comments
 (0)