Merge pull request #11726 from zhongwencool/audit-cli-args-bin

fix: cli's args in audit log should be array
This commit is contained in:
zhongwencool 2023-10-08 21:29:39 -05:00 committed by GitHub
commit 4898d2377b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{application, emqx_ctl, [ {application, emqx_ctl, [
{description, "Backend for emqx_ctl script"}, {description, "Backend for emqx_ctl script"},
{vsn, "0.1.4"}, {vsn, "0.1.5"},
{registered, []}, {registered, []},
{mod, {emqx_ctl_app, []}}, {mod, {emqx_ctl_app, []}},
{applications, [ {applications, [

View File

@ -331,13 +331,14 @@ safe_to_existing_atom(Str) ->
is_initialized() -> is_initialized() ->
ets:info(?CMD_TAB) =/= undefined. ets:info(?CMD_TAB) =/= undefined.
audit_log(Level, From, Log) -> audit_log(Level, From, Log = #{args := Args}) ->
case lookup_command(audit) of case lookup_command(audit) of
{error, _} -> {error, _} ->
ignore; ignore;
{ok, {Mod, Fun}} -> {ok, {Mod, Fun}} ->
try try
apply(Mod, Fun, [Level, From, Log]) Log1 = Log#{args => [unicode:characters_to_binary(A) || A <- Args]},
apply(Mod, Fun, [Level, From, Log1])
catch catch
_:Reason:Stacktrace -> _:Reason:Stacktrace ->
?LOG_ERROR(#{ ?LOG_ERROR(#{

View File

@ -2,7 +2,7 @@
{application, emqx_dashboard, [ {application, emqx_dashboard, [
{description, "EMQX Web Dashboard"}, {description, "EMQX Web Dashboard"},
% strict semver, bump manually! % strict semver, bump manually!
{vsn, "5.0.28"}, {vsn, "5.0.29"},
{modules, []}, {modules, []},
{registered, [emqx_dashboard_sup]}, {registered, [emqx_dashboard_sup]},
{applications, [ {applications, [

View File

@ -70,7 +70,7 @@ admins(_) ->
unload() -> unload() ->
emqx_ctl:unregister_command(admins). emqx_ctl:unregister_command(admins).
bin(S) -> iolist_to_binary(S). bin(S) -> unicode:characters_to_binary(S).
print_error(Reason) when is_binary(Reason) -> print_error(Reason) when is_binary(Reason) ->
emqx_ctl:print("Error: ~s~n", [Reason]). emqx_ctl:print("Error: ~s~n", [Reason]).