Validate Host header matches expected value before allowing access to MediaProxy
This commit is contained in:
parent
506a1c98e7
commit
843fcca5b4
2 changed files with 29 additions and 0 deletions
|
|
@ -54,6 +54,23 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyControllerTest do
|
|||
} = get(conn, "/proxy/hhgfh/eeee/fff")
|
||||
end
|
||||
|
||||
test "it returns a 400 for invalid host", %{conn: conn} do
|
||||
clear_config([:media_proxy, :base_url], "http://mp.localhost/")
|
||||
|
||||
url =
|
||||
MediaProxy.encode_url("https://pleroma.social/logo.jpeg")
|
||||
|> URI.parse()
|
||||
|> Map.put(:host, "wronghost")
|
||||
|> URI.to_string()
|
||||
|
||||
with_mock Pleroma.ReverseProxy,
|
||||
call: fn _conn, _url, _opts -> %Conn{status: :success} end do
|
||||
%{status: status} = get(conn, url)
|
||||
|
||||
assert status == 400
|
||||
end
|
||||
end
|
||||
|
||||
test "redirects to valid url when filename is invalidated", %{conn: conn, url: url} do
|
||||
invalid_url = String.replace(url, "test.png", "test-file.png")
|
||||
response = get(conn, invalid_url)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue