From eac30768289c98ff7767b5516110574cde7bc7ba Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 6 Oct 2022 16:50:05 -0400 Subject: [PATCH] Agent: Change typehint for build_monkey_commandline's location The function can handle str, PurePath, or None. This typehint change reflects that capability --- monkey/infection_monkey/utils/commands.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/monkey/infection_monkey/utils/commands.py b/monkey/infection_monkey/utils/commands.py index c290b3893..c8e1ad695 100644 --- a/monkey/infection_monkey/utils/commands.py +++ b/monkey/infection_monkey/utils/commands.py @@ -1,4 +1,5 @@ -from typing import List, Optional +from pathlib import PurePath +from typing import List, Optional, Union from infection_monkey.config import GUID from infection_monkey.exploit.tools.helpers import AGENT_BINARY_PATH_LINUX, AGENT_BINARY_PATH_WIN64 @@ -9,7 +10,9 @@ DROPPER_TARGET_PATH_LINUX = AGENT_BINARY_PATH_LINUX DROPPER_TARGET_PATH_WIN64 = AGENT_BINARY_PATH_WIN64 -def build_monkey_commandline(servers: List[str], depth: int, location: Optional[str] = None) -> str: +def build_monkey_commandline( + servers: List[str], depth: int, location: Union[str, PurePath, None] = None +) -> str: return " " + " ".join( build_monkey_commandline_explicitly( @@ -25,7 +28,7 @@ def build_monkey_commandline_explicitly( parent: Optional[str] = None, servers: Optional[List[str]] = None, depth: Optional[int] = None, - location: Optional[str] = None, + location: Union[str, PurePath, None] = None, ) -> List[str]: cmdline = []