Prevent exposure of sensitive information through metadata.
defmodule MyController do
use Plug.Logger
def handle_request(conn, _params) do
Logger.debug(fn -> inspect(conn) end)
send_resp(conn, 200, "OK")
end
end
This code can be vulnerable as it logs the entire connection object, including potentially sensitive information such as headers or parameters. If these logs are accessible, it could lead to an information leak.
defmodule MyController do
use Plug.Logger
def handle_request(conn, _params) do
Logger.debug(fn -> "Processing request" end)
send_resp(conn, 200, "OK")
end
end
This code is safer as it only logs a generic message, instead of the entire connection object. Thus, no sensitive information is logged.