Skip to content

Commit 859ee85

Browse files
Island: Add plugin manifests name if title is None in
monkey_exploitation
1 parent 95caf41 commit 859ee85

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

monkey/monkey_island/cc/services/reporting/exploitations/monkey_exploitation.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ def get_exploits_used_on_node(
6363
exploiter_titles = set()
6464
for exploit in successful_exploits:
6565
successful_exploiter_manifest = plugin_exploiter_manifests.get(exploit.exploiter_name)
66-
if successful_exploiter_manifest is not None:
67-
exploiter_titles.add(successful_exploiter_manifest.title)
66+
if successful_exploiter_manifest:
67+
if successful_exploiter_manifest.title:
68+
exploiter_titles.add(successful_exploiter_manifest.title)
69+
else:
70+
exploiter_titles.add(successful_exploiter_manifest.name)
6871

6972
# AgentPluginManifest title is Optional[str], list expects Iterable[str]
7073
return list(exploiter_titles) # type: ignore[arg-type]

monkey/tests/unit_tests/monkey_island/cc/services/reporting/exploitations/test_monkey_exploitation.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@
4646
exploiter_name="MockExploiter",
4747
)
4848

49+
EVENT_5 = ExploitationEvent(
50+
source=AGENT_ID,
51+
timestamp=TIMESTAMP,
52+
target=IPv4Address(TARGET_IP_STR),
53+
success=True,
54+
exploiter_name="Mock1Exploiter",
55+
)
56+
57+
4958
MACHINE = Machine(
5059
id=1,
5160
hardware_id=101,
@@ -64,7 +73,16 @@
6473
description="Mocked description",
6574
link_to_documentation="http://no_mocked.com",
6675
safe=True,
67-
)
76+
),
77+
"Mock1Exploiter": AgentPluginManifest(
78+
name="Mock1Exploiter",
79+
plugin_type=AgentPluginType.EXPLOITER,
80+
title=None,
81+
target_operating_systems=(OperatingSystem.WINDOWS,),
82+
description="Another Mocked description",
83+
link_to_documentation="http://nopenope.com",
84+
safe=True,
85+
),
6886
}
6987
}
7088

@@ -99,3 +117,8 @@ def test_get_exploits_used_on_node__mixed_exploits():
99117
def test_get_exploits_used_on_node__empty_plugin_manifests():
100118
exploits = get_exploits_used_on_node(MACHINE, [EVENT_1, EVENT_2, EVENT_3], {})
101119
assert sorted(exploits) == sorted(["SSH Exploiter", "Log4Shell Exploiter"])
120+
121+
122+
def test_get_exploits_used_on_node__empty_title():
123+
exploits = get_exploits_used_on_node(MACHINE, [EVENT_5], PLUGIN_MANIFESTS)
124+
assert sorted(exploits) == sorted(["Mock1Exploiter"])

0 commit comments

Comments
 (0)