Skip to content

Commit

Permalink
Island: Fix logic error in AgentSignalsService
Browse files Browse the repository at this point in the history
Issue #2817
PR #3065
  • Loading branch information
mssalvatore committed Mar 7, 2023
1 parent 90fd53d commit 3a96504
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion monkey/monkey_island/cc/services/agent_signals_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _agent_is_first_to_register(self, agent: Agent) -> bool:
first_to_register = min(
agents_on_same_machine, key=lambda a: a.registration_time, default=agent
)
return agent is first_to_register
return agent.id == first_to_register.id

def _agents_running_on_machine(self, machine_id: MachineID):
return [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from copy import copy
from unittest.mock import MagicMock
from uuid import UUID

Expand Down Expand Up @@ -75,7 +76,7 @@ def get_agent_by_id(agent_id: AgentID) -> Agent:
agent_repository.get_progenitor = MagicMock(return_value=AGENT_1)
agent_repository.get_agent_by_id = MagicMock(side_effect=get_agent_by_id)
agent_repository.get_running_agents = MagicMock(
return_value=[a for a in ALL_AGENTS if a.stop_time is None]
return_value=[copy(a) for a in ALL_AGENTS if a.stop_time is None]
)

return agent_repository
Expand Down

0 comments on commit 3a96504

Please sign in to comment.