From feaa7ee867ab3bfc89c3960839f3ed3c83975de5 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 21 Jun 2021 21:00:04 +0200 Subject: [PATCH] agent: Resolve empty space in build_monkey_commandline --- monkey/infection_monkey/utils/commands.py | 2 +- .../infection_monkey/utils/test_commands.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/monkey/infection_monkey/utils/commands.py b/monkey/infection_monkey/utils/commands.py index b2b5745ba..b9e042e00 100644 --- a/monkey/infection_monkey/utils/commands.py +++ b/monkey/infection_monkey/utils/commands.py @@ -7,7 +7,7 @@ def build_monkey_commandline( target_host: VictimHost, depth: int, vulnerable_port: str, location: str = None ) -> str: - return "".join( + return " ".join( build_monkey_commandline_explicitly( GUID, target_host.default_tunnel, diff --git a/monkey/tests/unit_tests/infection_monkey/utils/test_commands.py b/monkey/tests/unit_tests/infection_monkey/utils/test_commands.py index c43d02e41..ef96f022e 100644 --- a/monkey/tests/unit_tests/infection_monkey/utils/test_commands.py +++ b/monkey/tests/unit_tests/infection_monkey/utils/test_commands.py @@ -1,4 +1,7 @@ +from infection_monkey.config import GUID +from infection_monkey.model.host import VictimHost from infection_monkey.utils.commands import ( + build_monkey_commandline, build_monkey_commandline_explicitly, get_monkey_commandline_linux, get_monkey_commandline_windows, @@ -91,3 +94,15 @@ def test_get_monkey_commandline_linux(): ) assert expected == actual + + +def test_build_monkey_commandline(): + example_host = VictimHost(ip_addr="bla") + example_host.set_default_server("101010") + + expected = "-p " + GUID + " -s 101010 -d 0 -l /home/bla -vp 80" + actual = build_monkey_commandline( + target_host=example_host, depth=0, vulnerable_port="80", location="/home/bla" + ) + + assert expected == actual