Merge pull request #9410 from lafirest/newly_unsafe_atom
fix: fix newly found unsafe `binary_to_atom`
This commit is contained in:
commit
6e106ede66
|
@ -1,7 +1,7 @@
|
|||
%% -*- mode: erlang -*-
|
||||
{application, emqx_bridge, [
|
||||
{description, "An OTP application"},
|
||||
{vsn, "0.1.4"},
|
||||
{vsn, "0.1.5"},
|
||||
{registered, []},
|
||||
{mod, {emqx_bridge_app, []}},
|
||||
{applications, [
|
||||
|
|
|
@ -62,8 +62,15 @@ bridge_id(BridgeType, BridgeName) ->
|
|||
-spec parse_bridge_id(list() | binary() | atom()) -> {atom(), binary()}.
|
||||
parse_bridge_id(BridgeId) ->
|
||||
case string:split(bin(BridgeId), ":", all) of
|
||||
[Type, Name] -> {binary_to_atom(Type, utf8), Name};
|
||||
_ -> error({invalid_bridge_id, BridgeId})
|
||||
[Type, Name] ->
|
||||
case emqx_misc:safe_to_existing_atom(Type, utf8) of
|
||||
{ok, Type1} ->
|
||||
{Type1, Name};
|
||||
_ ->
|
||||
error({invalid_bridge_id, BridgeId})
|
||||
end;
|
||||
_ ->
|
||||
error({invalid_bridge_id, BridgeId})
|
||||
end.
|
||||
|
||||
reset_metrics(ResourceId) ->
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{application, emqx_dashboard, [
|
||||
{description, "EMQX Web Dashboard"},
|
||||
% strict semver, bump manually!
|
||||
{vsn, "5.0.7"},
|
||||
{vsn, "5.0.8"},
|
||||
{modules, []},
|
||||
{registered, [emqx_dashboard_sup]},
|
||||
{applications, [kernel, stdlib, mnesia, minirest, emqx]},
|
||||
|
|
|
@ -121,13 +121,21 @@ fields(sampler_current) ->
|
|||
|
||||
monitor(get, #{query_string := QS, bindings := Bindings}) ->
|
||||
Latest = maps:get(<<"latest">>, QS, infinity),
|
||||
Node = binary_to_atom(maps:get(node, Bindings, <<"all">>)),
|
||||
RawNode = maps:get(node, Bindings, all),
|
||||
case emqx_misc:safe_to_existing_atom(RawNode, utf8) of
|
||||
{ok, Node} ->
|
||||
case emqx_dashboard_monitor:samplers(Node, Latest) of
|
||||
{badrpc, {Node, Reason}} ->
|
||||
Message = list_to_binary(io_lib:format("Bad node ~p, rpc failed ~p", [Node, Reason])),
|
||||
Message = list_to_binary(
|
||||
io_lib:format("Bad node ~p, rpc failed ~p", [Node, Reason])
|
||||
),
|
||||
{400, 'BAD_RPC', Message};
|
||||
Samplers ->
|
||||
{200, Samplers}
|
||||
end;
|
||||
_ ->
|
||||
Message = list_to_binary(io_lib:format("Bad node ~p", [RawNode])),
|
||||
{400, 'BAD_RPC', Message}
|
||||
end.
|
||||
|
||||
monitor_current(get, #{bindings := Bindings}) ->
|
||||
|
|
Loading…
Reference in New Issue