Explorar o código

chore: redact some audit logs from CLI

JianBo He %!s(int64=2) %!d(string=hai) anos
pai
achega
b970a34ee0
Modificáronse 1 ficheiros con 11 adicións e 1 borrados
  1. 11 1
      apps/emqx_conf/src/emqx_conf_cli.erl

+ 11 - 1
apps/emqx_conf/src/emqx_conf_cli.erl

@@ -108,7 +108,17 @@ admins(_) ->
     emqx_ctl:usage(usage_sync()).
     emqx_ctl:usage(usage_sync()).
 
 
 audit(Level, From, Log) ->
 audit(Level, From, Log) ->
-    ?AUDIT(Level, From, Log#{time => logger:timestamp()}).
+    Log1 = redact(Log#{time => logger:timestamp()}),
+    ?AUDIT(Level, From, Log1).
+
+redact(Logs = #{cmd := admins, args := ["add", Username, _Password | Rest]}) ->
+    Logs#{args => ["add", Username, "******" | Rest]};
+redact(Logs = #{cmd := admins, args := ["passwd", Username, _Password]}) ->
+    Logs#{args => ["passwd", Username, "******"]};
+redact(Logs = #{cmd := license, args := ["update", _License]}) ->
+    Logs#{args => ["update", "******"]};
+redact(Logs) ->
+    Logs.
 
 
 usage_conf() ->
 usage_conf() ->
     [
     [