forked from p15670423/monkey
Agent: Reword note in control
Rewrite control set proxy UT, fix typo in httpfinger
This commit is contained in:
parent
a8182cbb3d
commit
cd23eb2909
|
@ -121,7 +121,8 @@ class ControlClient(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_proxies(proxy_find):
|
def set_proxies(proxy_find):
|
||||||
"""
|
"""
|
||||||
Note: Proxy schema changes which causes the machine to not open a tunnel back.
|
Note: The proxy schema changes between different versions of requests and urllib3,
|
||||||
|
which causes the machine to not open a tunnel back.
|
||||||
If we get "ValueError: check_hostname requires server_hostname" or
|
If we get "ValueError: check_hostname requires server_hostname" or
|
||||||
"Proxy URL had not schema, should start with http:// or https://" errors,
|
"Proxy URL had not schema, should start with http:// or https://" errors,
|
||||||
the proxy schema needs to be changed.
|
the proxy schema needs to be changed.
|
||||||
|
|
|
@ -44,7 +44,7 @@ class HTTPFinger(HostFinger):
|
||||||
logger.info("Port %d is open on host %s " % (port[0], host))
|
logger.info("Port %d is open on host %s " % (port[0], host))
|
||||||
break # https will be the same on the same port
|
break # https will be the same on the same port
|
||||||
except Timeout:
|
except Timeout:
|
||||||
logger.debug(f"Timout while requesting headers from {url}")
|
logger.debug(f"Timeout while requesting headers from {url}")
|
||||||
except ConnectionError: # Someone doesn't like us
|
except ConnectionError: # Someone doesn't like us
|
||||||
logger.debug(f"Connection error while requesting headers from {url}")
|
logger.debug(f"Connection error while requesting headers from {url}")
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,15 @@ import pytest
|
||||||
|
|
||||||
from monkey.infection_monkey.control import ControlClient
|
from monkey.infection_monkey.control import ControlClient
|
||||||
|
|
||||||
PROXY_FOUND = ("8.8.8.8", "45455")
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
@pytest.mark.parametrize("is_windows_os", [True, False])
|
"is_windows_os,expected_proxy_string",
|
||||||
def test_control_set_proxies(monkeypatch, is_windows_os):
|
[(True, "http://8.8.8.8:45455"), (False, "8.8.8.8:45455")],
|
||||||
|
)
|
||||||
|
def test_control_set_proxies(monkeypatch, is_windows_os, expected_proxy_string):
|
||||||
monkeypatch.setattr("monkey.infection_monkey.control.is_windows_os", lambda: is_windows_os)
|
monkeypatch.setattr("monkey.infection_monkey.control.is_windows_os", lambda: is_windows_os)
|
||||||
control_client = ControlClient()
|
control_client = ControlClient()
|
||||||
|
|
||||||
control_client.set_proxies(PROXY_FOUND)
|
control_client.set_proxies(("8.8.8.8", "45455"))
|
||||||
|
|
||||||
if is_windows_os:
|
assert control_client.proxies["https"] == expected_proxy_string
|
||||||
assert control_client.proxies["https"].startswith("http://")
|
|
||||||
else:
|
|
||||||
assert control_client.proxies["https"].startswith(PROXY_FOUND[0])
|
|
||||||
|
|
Loading…
Reference in New Issue