mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 01:38:15 +00:00
fix: do not render regexp hostname in debug endpoint response
This commit is contained in:
parent
a79445feef
commit
fdb7310cda
@ -380,7 +380,8 @@ upstream {{ $vpath.upstream }} {
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- $debug_vhost := deepCopy .VHost }}
|
{{- $debug_vhost := deepCopy .VHost }}
|
||||||
{{- $_ := set $debug_vhost "hostname" .Hostname }}
|
{{- /* If it's a regexp, do not render the Hostname to the response to avoid rendering config breaking characters */}}
|
||||||
|
{{- $_ := set $debug_vhost "hostname" (.VHost.is_regexp | ternary "Hostname is a regexp and unsafe to include in the debug response." .Hostname) }}
|
||||||
{{- $_ := set $debug_vhost "paths" $debug_paths }}
|
{{- $_ := set $debug_vhost "paths" $debug_paths }}
|
||||||
|
|
||||||
{{- $debug_response := dict
|
{{- $debug_response := dict
|
||||||
|
@ -19,7 +19,7 @@ def test_debug_endpoint_response_contains_expected_values(docker_compose, nginxp
|
|||||||
assert jsonResponse["vhost"]["enable_debug_endpoint"] == True
|
assert jsonResponse["vhost"]["enable_debug_endpoint"] == True
|
||||||
|
|
||||||
|
|
||||||
def test_debug_endpoint_pahts_stripped_if_response_too_long(docker_compose, nginxproxy):
|
def test_debug_endpoint_paths_stripped_if_response_too_long(docker_compose, nginxproxy):
|
||||||
r = nginxproxy.get("http://stripped.debug.nginx-proxy.example/nginx-proxy-debug")
|
r = nginxproxy.get("http://stripped.debug.nginx-proxy.example/nginx-proxy-debug")
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
try:
|
try:
|
||||||
@ -31,6 +31,16 @@ def test_debug_endpoint_pahts_stripped_if_response_too_long(docker_compose, ngin
|
|||||||
assert jsonResponse["warning"] == "Virtual paths configuration for this hostname is too large and has been stripped from response."
|
assert jsonResponse["warning"] == "Virtual paths configuration for this hostname is too large and has been stripped from response."
|
||||||
|
|
||||||
|
|
||||||
|
def test_debug_endpoint_hostname_replaced_by_warning_if_regexp(docker_compose, nginxproxy):
|
||||||
|
r = nginxproxy.get("http://regexp.foo.debug.nginx-proxy.example/nginx-proxy-debug")
|
||||||
|
assert r.status_code == 200
|
||||||
|
try:
|
||||||
|
jsonResponse = json.loads(r.text)
|
||||||
|
except ValueError as err:
|
||||||
|
pytest.fail("Failed to parse debug endpoint response as JSON: %s" % err, pytrace=False)
|
||||||
|
assert jsonResponse["vhost"]["hostname"] == "Hostname is a regexp and unsafe to include in the debug response."
|
||||||
|
|
||||||
|
|
||||||
def test_debug_endpoint_is_disabled_per_container(docker_compose, nginxproxy):
|
def test_debug_endpoint_is_disabled_per_container(docker_compose, nginxproxy):
|
||||||
r = nginxproxy.get("http://disabled.debug.nginx-proxy.example/nginx-proxy-debug")
|
r = nginxproxy.get("http://disabled.debug.nginx-proxy.example/nginx-proxy-debug")
|
||||||
assert r.status_code == 404
|
assert r.status_code == 404
|
||||||
|
@ -42,6 +42,14 @@ services:
|
|||||||
"/18":
|
"/18":
|
||||||
"/19":
|
"/19":
|
||||||
"/20":
|
"/20":
|
||||||
|
|
||||||
|
debug_regexp:
|
||||||
|
image: web
|
||||||
|
expose:
|
||||||
|
- "84"
|
||||||
|
environment:
|
||||||
|
WEB_PORTS: 84
|
||||||
|
VIRTUAL_HOST: ~^regexp.*\.debug.nginx-proxy.example
|
||||||
|
|
||||||
debug_disabled:
|
debug_disabled:
|
||||||
image: web
|
image: web
|
||||||
|
Loading…
x
Reference in New Issue
Block a user