Skip to content

Commit ab72092

Browse files
Merge commit from fork
1 parent f4cfecc commit ab72092

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

distributed/dashboard/tests/test_scheduler_bokeh.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,17 @@ async def test_proxy_to_workers(c, s, a, b):
10991099
assert response_direct.code == 200
11001100
assert b"System" in response_direct.body
11011101

1102+
if proxy_exists:
1103+
dashboard_port = s.http_server.port
1104+
http_client = AsyncHTTPClient()
1105+
unsafe_host = "<><><>" # Some unsafe characters that should be escaped
1106+
proxy_url = f"http://localhost:{dashboard_port}/proxy/1234/{unsafe_host}/status"
1107+
response = await http_client.fetch(proxy_url, raise_error=False)
1108+
assert response.code == 400
1109+
assert (
1110+
unsafe_host not in response.body.decode()
1111+
), "Unsafe characters should be escaped"
1112+
11021113

11031114
@gen_cluster(
11041115
client=True,

distributed/http/proxy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import html
34
import logging
45

56
from tornado import web
@@ -46,7 +47,7 @@ async def http_get(self, port, host, proxied_path):
4647

4748
worker = f"{self.host}:{port}"
4849
if not check_worker_dashboard_exits(self.scheduler, worker):
49-
msg = "Worker <%s> does not exist" % worker
50+
msg = f"Worker &lt;{html.escape(worker)}&gt; does not exist"
5051
self.set_status(400)
5152
self.finish(msg)
5253
return

0 commit comments

Comments
 (0)