From db965e14f84fa3ad68419586b41d9102c79454e8 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 1 Feb 2022 13:57:54 +0530 Subject: [PATCH] Agent: Remove do_POST in HTTPConnectProxyHandler As per https://github.com/guardicore/monkey/pull/527, this code was added for the bootloader. Now that we're removing the bootloader, this is no longer needed. --- monkey/infection_monkey/transport/http.py | 30 ----------------------- 1 file changed, 30 deletions(-) diff --git a/monkey/infection_monkey/transport/http.py b/monkey/infection_monkey/transport/http.py index 910d79bf4..f8ca906b0 100644 --- a/monkey/infection_monkey/transport/http.py +++ b/monkey/infection_monkey/transport/http.py @@ -7,11 +7,7 @@ import urllib from logging import getLogger from urllib.parse import urlsplit -import requests - -import infection_monkey.control import infection_monkey.monkeyfs as monkeyfs -from common.common_consts.timeouts import SHORT_REQUEST_TIMEOUT from infection_monkey.network.tools import get_interface_to_target from infection_monkey.transport.base import TransportProxyBase, update_last_serve_time @@ -114,32 +110,6 @@ class FileServHTTPRequestHandler(http.server.BaseHTTPRequestHandler): class HTTPConnectProxyHandler(http.server.BaseHTTPRequestHandler): timeout = 30 # timeout with clients, set to None not to make persistent connection - def do_POST(self): - try: - content_length = int(self.headers["Content-Length"]) - post_data = self.rfile.read(content_length).decode() - logger.info("Received bootloader's request: {}".format(post_data)) - try: - dest_path = self.path - r = requests.post( # noqa: DUO123 - url=dest_path, - data=post_data, - verify=False, - proxies=infection_monkey.control.ControlClient.proxies, - timeout=SHORT_REQUEST_TIMEOUT, - ) - self.send_response(r.status_code) - except requests.exceptions.ConnectionError as e: - logger.error("Couldn't forward request to the island: {}".format(e)) - self.send_response(404) - except Exception as e: - logger.error("Failed to forward bootloader request: {}".format(e)) - finally: - self.end_headers() - self.wfile.write(r.content) - except Exception as e: - logger.error("Failed receiving bootloader telemetry: {}".format(e)) - def version_string(self): return ""