test(emqx_mgmt): Exempt do_query function from BPAPI static check
This commit is contained in:
parent
97078002f2
commit
a469c466a6
|
@ -52,6 +52,11 @@
|
||||||
-define(RPC_FUNCTIONS, "emqx_cluster_rpc:multicall/3, emqx_cluster_rpc:multicall/5").
|
-define(RPC_FUNCTIONS, "emqx_cluster_rpc:multicall/3, emqx_cluster_rpc:multicall/5").
|
||||||
%% List of functions in the RPC backend modules that we can ignore:
|
%% List of functions in the RPC backend modules that we can ignore:
|
||||||
-define(IGNORED_RPC_CALLS, "gen_rpc:nodes/0").
|
-define(IGNORED_RPC_CALLS, "gen_rpc:nodes/0").
|
||||||
|
%% List of business-layer functions that are exempt from the checks:
|
||||||
|
-define(EXEMPTIONS, "emqx_mgmt_api:do_query/6" % Reason: legacy code. A fun and a QC query are
|
||||||
|
% passed in the args, it's futile to try to statically
|
||||||
|
% check it
|
||||||
|
).
|
||||||
|
|
||||||
-define(XREF, myxref).
|
-define(XREF, myxref).
|
||||||
|
|
||||||
|
@ -207,7 +212,7 @@ prepare(#{reldir := RelDir, plt := PLT}) ->
|
||||||
dialyzer_plt:from_file(PLT).
|
dialyzer_plt:from_file(PLT).
|
||||||
|
|
||||||
find_remote_calls(_Opts) ->
|
find_remote_calls(_Opts) ->
|
||||||
Query = "XC | (A - [" ?IGNORED_APPS "]:App - [" ?IGNORED_MODULES "] : Mod)
|
Query = "XC | (A - [" ?IGNORED_APPS "]:App - [" ?IGNORED_MODULES "]:Mod - [" ?EXEMPTIONS "])
|
||||||
|| (([" ?RPC_MODULES "] : Mod + [" ?RPC_FUNCTIONS "]) - " ?IGNORED_RPC_CALLS ")",
|
|| (([" ?RPC_MODULES "] : Mod + [" ?RPC_FUNCTIONS "]) - " ?IGNORED_RPC_CALLS ")",
|
||||||
{ok, Calls} = xref:q(?XREF, Query),
|
{ok, Calls} = xref:q(?XREF, Query),
|
||||||
?INFO("Calls to RPC modules ~p", [Calls]),
|
?INFO("Calls to RPC modules ~p", [Calls]),
|
||||||
|
|
|
@ -197,12 +197,15 @@ do_cluster_query([Node | Tail] = Nodes, Tab, Qs, QueryFun, Continuation,
|
||||||
%% Do Query (or rpc query)
|
%% Do Query (or rpc query)
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
%% @private
|
%% @private This function is exempt from BPAPI
|
||||||
do_query(Node, Tab, Qs, {M,F}, Continuation, Limit) when Node =:= node() ->
|
do_query(Node, Tab, Qs, {M,F}, Continuation, Limit) when Node =:= node() ->
|
||||||
erlang:apply(M, F, [Tab, Qs, Continuation, Limit]);
|
erlang:apply(M, F, [Tab, Qs, Continuation, Limit]);
|
||||||
do_query(Node, Tab, Qs, QueryFun, Continuation, Limit) ->
|
do_query(Node, Tab, Qs, QueryFun, Continuation, Limit) ->
|
||||||
rpc_call(Node, ?MODULE, do_query,
|
case rpc:call(Node, ?MODULE, do_query,
|
||||||
[Node, Tab, Qs, QueryFun, Continuation, Limit], 50000).
|
[Node, Tab, Qs, QueryFun, Continuation, Limit], 50000) of
|
||||||
|
{badrpc, _} = R -> {error, R};
|
||||||
|
Ret -> Ret
|
||||||
|
end.
|
||||||
|
|
||||||
sub_query_result(Len, Rows, Limit, Results, Meta) ->
|
sub_query_result(Len, Rows, Limit, Results, Meta) ->
|
||||||
{Flag, NMeta} = judge_page_with_counting(Len, Meta),
|
{Flag, NMeta} = judge_page_with_counting(Len, Meta),
|
||||||
|
@ -219,13 +222,6 @@ sub_query_result(Len, Rows, Limit, Results, Meta) ->
|
||||||
end,
|
end,
|
||||||
{NMeta, NResults}.
|
{NMeta, NResults}.
|
||||||
|
|
||||||
%% @private
|
|
||||||
rpc_call(Node, M, F, A, T) ->
|
|
||||||
case rpc:call(Node, M, F, A, T) of
|
|
||||||
{badrpc, _} = R -> {error, R};
|
|
||||||
Res -> Res
|
|
||||||
end.
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Table Select
|
%% Table Select
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue