From d3779a32190222e6d56d8562f9733599b05bf49b Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Tue, 26 Sep 2023 12:08:07 +0200 Subject: [PATCH 1/2] fix(audit): make 'emqx eval' command auditable --- bin/nodetool | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/nodetool b/bin/nodetool index d00d14a12..ab2210aa5 100755 --- a/bin/nodetool +++ b/bin/nodetool @@ -140,11 +140,12 @@ do(Args) -> io:format("~p\n", [Other]) end; ["eval" | ListOfArgs] -> + % parse args locally in the remsh node Parsed = parse_eval_args(ListOfArgs), % 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} -> - io:format("~p~n",[Value]); + io:format("~p~n", [Value]); {badrpc, Reason} -> io:format("RPC to ~p failed: ~p~n", [TargetNode, Reason]), halt(1) From 5e08c436dac8921bbe3932fdf6768570f59f1110 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Tue, 26 Sep 2023 14:29:42 +0200 Subject: [PATCH 2/2] test: add bat test for corrupted cluster.hocon --- scripts/test/emqx-boot.bats | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/test/emqx-boot.bats b/scripts/test/emqx-boot.bats index 96f9a4457..13a505ce4 100644 --- a/scripts/test/emqx-boot.bats +++ b/scripts/test/emqx-boot.bats @@ -12,10 +12,18 @@ [[ "$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" echo "{" > $conffile run ./_build/$PROFILE/rel/emqx/bin/emqx console [[ $status -ne 0 ]] 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 +}