From 2e5e55af9ae97aa41b5d0eb9c0a2000fe8b3e2a4 Mon Sep 17 00:00:00 2001 From: A_D Date: Sun, 20 Jun 2021 17:44:29 +0200 Subject: [PATCH] Applied requested changes --- PLUGINS.md | 2 +- debug_webserver.py | 3 ++- plugins/edsm.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/PLUGINS.md b/PLUGINS.md index f55e88b7..5a7388b7 100644 --- a/PLUGINS.md +++ b/PLUGINS.md @@ -1055,7 +1055,7 @@ If said string exists, `DEBUG_WEBSERVER_HOST` and `DEBUG_WEBSERVER_PORT` in `edmc_data` will contain the host and port for the currently running local webserver. Simply redirect your requests there, and your requests will be logged to disk. For organisation, rewrite your request path to simply be `/pluginname`. -logs exist in `$TEMP/EDMarketConnector/http_debug/$path.log`. If somehow you manage to cause a directory traversal, your +Logs exist in `$TEMP/EDMarketConnector/http_debug/$path.log`. If somehow you manage to cause a directory traversal, your data will not be saved to disk at all. You will see this in EDMCs log. The simplest way to go about adding support is: diff --git a/debug_webserver.py b/debug_webserver.py index a3f60b4c..3d1a671b 100644 --- a/debug_webserver.py +++ b/debug_webserver.py @@ -47,6 +47,7 @@ class LoggingHandler(server.BaseHTTPRequestHandler): self.send_response_only(200, "OK") if response is not None: self.send_header('Content-Length', str(len(response))) + self.end_headers() # This is needed because send_response_only DOESN'T ACTUALLY SEND THE RESPONSE if response is not None: self.wfile.write(response.encode()) @@ -63,7 +64,7 @@ class LoggingHandler(server.BaseHTTPRequestHandler): target_file = output_data_path / (safe_file_name(target_path) + '.log') if target_file.parent != output_data_path: logger.warning(f"REFUSING TO WRITE FILE THAT ISN'T IN THE RIGHT PLACE! {target_file=}") - logger.warn(f'DATA FOLLOWS\n{data}') + logger.warning(f'DATA FOLLOWS\n{data}') return with output_lock, target_file.open('a') as f: diff --git a/plugins/edsm.py b/plugins/edsm.py index c1f8bf7f..4681cc7b 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -536,7 +536,7 @@ if 'edsm' in debug_senders: # Worker thread -def worker() -> None: +def worker() -> None: # noqa: CCR001 C901 # Cant be broken up currently """ Handle uploading events to EDSM API.