Merge pull request #11688 from zmstone/0926-audit-eval-command
fix(audit): make 'emqx eval' command auditable
This commit is contained in:
commit
5614fd50e0
|
@ -140,11 +140,12 @@ do(Args) ->
|
||||||
io:format("~p\n", [Other])
|
io:format("~p\n", [Other])
|
||||||
end;
|
end;
|
||||||
["eval" | ListOfArgs] ->
|
["eval" | ListOfArgs] ->
|
||||||
|
% parse args locally in the remsh node
|
||||||
Parsed = parse_eval_args(ListOfArgs),
|
Parsed = parse_eval_args(ListOfArgs),
|
||||||
% and evaluate it on the remote node
|
% and evaluate it on the remote node
|
||||||
case rpc:call(TargetNode, emqx_ctl, eval_erl, [Parsed]) of
|
case rpc:call(TargetNode, emqx_ctl, run_command, [eval_erl, Parsed], infinity) of
|
||||||
{ok, Value} ->
|
{ok, Value} ->
|
||||||
io:format("~p~n",[Value]);
|
io:format("~p~n", [Value]);
|
||||||
{badrpc, Reason} ->
|
{badrpc, Reason} ->
|
||||||
io:format("RPC to ~p failed: ~p~n", [TargetNode, Reason]),
|
io:format("RPC to ~p failed: ~p~n", [TargetNode, Reason]),
|
||||||
halt(1)
|
halt(1)
|
||||||
|
|
|
@ -12,10 +12,18 @@
|
||||||
[[ "$output" =~ "ERROR: Invalid node name,".+ ]]
|
[[ "$output" =~ "ERROR: Invalid node name,".+ ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "corrupted cluster config file" {
|
@test "corrupted cluster-override.conf" {
|
||||||
conffile="./_build/$PROFILE/rel/emqx/data/configs/cluster-override.conf"
|
conffile="./_build/$PROFILE/rel/emqx/data/configs/cluster-override.conf"
|
||||||
echo "{" > $conffile
|
echo "{" > $conffile
|
||||||
run ./_build/$PROFILE/rel/emqx/bin/emqx console
|
run ./_build/$PROFILE/rel/emqx/bin/emqx console
|
||||||
[[ $status -ne 0 ]]
|
[[ $status -ne 0 ]]
|
||||||
rm -f $conffile
|
rm -f $conffile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "corrupted cluster.hocon" {
|
||||||
|
conffile="./_build/$PROFILE/rel/emqx/data/configs/cluster.hocon"
|
||||||
|
echo "{" > $conffile
|
||||||
|
run ./_build/$PROFILE/rel/emqx/bin/emqx console
|
||||||
|
[[ $status -ne 0 ]]
|
||||||
|
rm -f $conffile
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue