25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Log message when trying to execute http_api command with extra arguments

This commit is contained in:
Paweł Chmielowski 2019-04-03 11:50:15 +02:00
parent 33c10867e3
commit 65a6532cd9

View File

@ -307,7 +307,7 @@ handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
{400, iolist_to_binary(Msg)}; {400, iolist_to_binary(Msg)};
?EX_RULE(Class, Error, Stack) -> ?EX_RULE(Class, Error, Stack) ->
?ERROR_MSG("REST API Error: " ?ERROR_MSG("REST API Error: "
"~s(~p) -> ~p:~p ~p", "~s(~p) -> ~p:~p ~p",
[Call, hide_sensitive_args(Args), [Call, hide_sensitive_args(Args),
Class, Error, ?EX_STACK(Stack)]), Class, Error, ?EX_STACK(Stack)]),
{500, <<"internal_error">>} {500, <<"internal_error">>}
@ -322,7 +322,7 @@ handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
handle2(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) -> handle2(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
{ArgsF, _ResultF} = ejabberd_commands:get_command_format(Call, Auth, Version), {ArgsF, _ResultF} = ejabberd_commands:get_command_format(Call, Auth, Version),
ArgsFormatted = format_args(Args, ArgsF), ArgsFormatted = format_args(Call, Args, ArgsF),
case ejabberd_commands:execute_command2(Call, ArgsFormatted, Auth, Version) of case ejabberd_commands:execute_command2(Call, ArgsFormatted, Auth, Version) of
{error, Error} -> {error, Error} ->
throw(Error); throw(Error);
@ -346,7 +346,7 @@ get_elem_delete(A, L, F) ->
end end
end. end.
format_args(Args, ArgsFormat) -> format_args(Call, Args, ArgsFormat) ->
{ArgsRemaining, R} = lists:foldl(fun ({ArgName, {ArgsRemaining, R} = lists:foldl(fun ({ArgName,
ArgFormat}, ArgFormat},
{Args1, Res}) -> {Args1, Res}) ->
@ -361,9 +361,11 @@ format_args(Args, ArgsFormat) ->
case ArgsRemaining of case ArgsRemaining of
[] -> R; [] -> R;
L when is_list(L) -> L when is_list(L) ->
ExtraArgs = [N || {N, _} <- L],
?INFO_MSG("Command ~s call rejected, it has unknown arguments ~w",
[Call, ExtraArgs]),
throw({invalid_parameter, throw({invalid_parameter,
io_lib:format("Request have unknown arguments: ~w", io_lib:format("Request have unknown arguments: ~w", [ExtraArgs])})
[[N || {N, _} <- L]])})
end. end.
format_arg({Elements}, format_arg({Elements},