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 -*-
|
%% -*- mode: erlang -*-
|
||||||
{application, emqx_bridge, [
|
{application, emqx_bridge, [
|
||||||
{description, "An OTP application"},
|
{description, "An OTP application"},
|
||||||
{vsn, "0.1.4"},
|
{vsn, "0.1.5"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{mod, {emqx_bridge_app, []}},
|
{mod, {emqx_bridge_app, []}},
|
||||||
{applications, [
|
{applications, [
|
||||||
|
|
|
@ -62,8 +62,15 @@ bridge_id(BridgeType, BridgeName) ->
|
||||||
-spec parse_bridge_id(list() | binary() | atom()) -> {atom(), binary()}.
|
-spec parse_bridge_id(list() | binary() | atom()) -> {atom(), binary()}.
|
||||||
parse_bridge_id(BridgeId) ->
|
parse_bridge_id(BridgeId) ->
|
||||||
case string:split(bin(BridgeId), ":", all) of
|
case string:split(bin(BridgeId), ":", all) of
|
||||||
[Type, Name] -> {binary_to_atom(Type, utf8), Name};
|
[Type, Name] ->
|
||||||
_ -> error({invalid_bridge_id, BridgeId})
|
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.
|
end.
|
||||||
|
|
||||||
reset_metrics(ResourceId) ->
|
reset_metrics(ResourceId) ->
|
||||||
|
|
|
@ -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.7"},
|
{vsn, "5.0.8"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [emqx_dashboard_sup]},
|
{registered, [emqx_dashboard_sup]},
|
||||||
{applications, [kernel, stdlib, mnesia, minirest, emqx]},
|
{applications, [kernel, stdlib, mnesia, minirest, emqx]},
|
||||||
|
|
|
@ -121,13 +121,21 @@ fields(sampler_current) ->
|
||||||
|
|
||||||
monitor(get, #{query_string := QS, bindings := Bindings}) ->
|
monitor(get, #{query_string := QS, bindings := Bindings}) ->
|
||||||
Latest = maps:get(<<"latest">>, QS, infinity),
|
Latest = maps:get(<<"latest">>, QS, infinity),
|
||||||
Node = binary_to_atom(maps:get(node, Bindings, <<"all">>)),
|
RawNode = maps:get(node, Bindings, all),
|
||||||
case emqx_dashboard_monitor:samplers(Node, Latest) of
|
case emqx_misc:safe_to_existing_atom(RawNode, utf8) of
|
||||||
{badrpc, {Node, Reason}} ->
|
{ok, Node} ->
|
||||||
Message = list_to_binary(io_lib:format("Bad node ~p, rpc failed ~p", [Node, Reason])),
|
case emqx_dashboard_monitor:samplers(Node, Latest) of
|
||||||
{400, 'BAD_RPC', Message};
|
{badrpc, {Node, Reason}} ->
|
||||||
Samplers ->
|
Message = list_to_binary(
|
||||||
{200, Samplers}
|
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.
|
end.
|
||||||
|
|
||||||
monitor_current(get, #{bindings := Bindings}) ->
|
monitor_current(get, #{bindings := Bindings}) ->
|
||||||
|
|
Loading…
Reference in New Issue