Browse Source

fix: do not leak action configurations in alarm messages

Kjell Winblad 1 year ago
parent
commit
4b540e3bd0
1 changed files with 12 additions and 3 deletions
  1. 12 3
      apps/emqx_resource/src/emqx_resource_manager.erl

+ 12 - 3
apps/emqx_resource/src/emqx_resource_manager.erl

@@ -1431,9 +1431,13 @@ maybe_alarm(_Status, _ResId, Error, Error) ->
 maybe_alarm(_Status, ResId, Error, _PrevError) ->
     HrError =
         case Error of
-            {error, undefined} -> <<"Unknown reason">>;
-            {error, Reason} -> emqx_utils:readable_error_msg(Reason);
-            _ -> emqx_utils:readable_error_msg(Error)
+            {error, undefined} ->
+                <<"Unknown reason">>;
+            {error, Reason} ->
+                emqx_utils:readable_error_msg(Reason);
+            _ ->
+                Error1 = redact_config_from_error_status(Error),
+                emqx_utils:readable_error_msg(Error1)
         end,
     emqx_alarm:safe_activate(
         ResId,
@@ -1442,6 +1446,11 @@ maybe_alarm(_Status, ResId, Error, _PrevError) ->
     ),
     ?tp(resource_activate_alarm, #{resource_id => ResId}).
 
+redact_config_from_error_status(#{config := _} = ErrorStatus) ->
+    maps:remove(config, ErrorStatus);
+redact_config_from_error_status(Error) ->
+    Error.
+
 -spec maybe_resume_resource_workers(resource_id(), resource_status()) -> ok.
 maybe_resume_resource_workers(ResId, ?status_connected) ->
     lists:foreach(