forked from p15670423/monkey
Agent: Remove send_config_error from ControlClient
This commit is contained in:
parent
6314ddd71a
commit
153436371b
|
@ -14,7 +14,6 @@ HIDDEN_FIELD_REPLACEMENT_CONTENT = "hidden"
|
||||||
|
|
||||||
class Configuration(object):
|
class Configuration(object):
|
||||||
def from_kv(self, formatted_data):
|
def from_kv(self, formatted_data):
|
||||||
unknown_items = []
|
|
||||||
for key, value in list(formatted_data.items()):
|
for key, value in list(formatted_data.items()):
|
||||||
if key.startswith("_"):
|
if key.startswith("_"):
|
||||||
continue
|
continue
|
||||||
|
@ -22,11 +21,8 @@ class Configuration(object):
|
||||||
continue
|
continue
|
||||||
if hasattr(self, key):
|
if hasattr(self, key):
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
else:
|
|
||||||
unknown_items.append(key)
|
|
||||||
if not self.max_depth:
|
if not self.max_depth:
|
||||||
self.max_depth = self.depth
|
self.max_depth = self.depth
|
||||||
return unknown_items
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def hide_sensitive_info(config_dict):
|
def hide_sensitive_info(config_dict):
|
||||||
|
|
|
@ -185,7 +185,7 @@ class ControlClient(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
unknown_variables = WormConfiguration.from_kv(reply.json().get("config"))
|
WormConfiguration.from_kv(reply.json().get("config"))
|
||||||
formatted_config = pformat(
|
formatted_config = pformat(
|
||||||
WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict())
|
WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict())
|
||||||
)
|
)
|
||||||
|
@ -200,28 +200,6 @@ class ControlClient(object):
|
||||||
)
|
)
|
||||||
raise Exception("Couldn't load from from server's configuration, aborting. %s" % exc)
|
raise Exception("Couldn't load from from server's configuration, aborting. %s" % exc)
|
||||||
|
|
||||||
if unknown_variables:
|
|
||||||
ControlClient.send_config_error()
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def send_config_error():
|
|
||||||
if not WormConfiguration.current_server:
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
requests.patch( # noqa: DUO123
|
|
||||||
f"https://{WormConfiguration.current_server}/api/agent/{GUID}",
|
|
||||||
data=json.dumps({"config_error": True}),
|
|
||||||
headers={"content-type": "application/json"},
|
|
||||||
verify=False,
|
|
||||||
proxies=ControlClient.proxies,
|
|
||||||
timeout=MEDIUM_REQUEST_TIMEOUT,
|
|
||||||
)
|
|
||||||
except Exception as exc:
|
|
||||||
logger.warning(
|
|
||||||
"Error connecting to control server %s: %s", WormConfiguration.current_server, exc
|
|
||||||
)
|
|
||||||
return {}
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_control_tunnel():
|
def create_control_tunnel():
|
||||||
if not WormConfiguration.current_server:
|
if not WormConfiguration.current_server:
|
||||||
|
|
Loading…
Reference in New Issue