Merge pull request #6936 from terry-xiaoyu/empty_rule_id
fix(rule): deny POST empty rule ids
This commit is contained in:
commit
ce05c14ef2
|
@ -199,7 +199,10 @@ param_path_id() ->
|
||||||
{200, format_rule_resp(Records)};
|
{200, format_rule_resp(Records)};
|
||||||
|
|
||||||
'/rules'(post, #{body := Params0}) ->
|
'/rules'(post, #{body := Params0}) ->
|
||||||
Id = maps:get(<<"id">>, Params0, list_to_binary(emqx_misc:gen_id(8))),
|
case maps:get(<<"id">>, Params0, list_to_binary(emqx_misc:gen_id(8))) of
|
||||||
|
<<>> ->
|
||||||
|
{400, #{code => 'BAD_ARGS', message => <<"empty rule id is not allowed">>}};
|
||||||
|
Id ->
|
||||||
Params = filter_out_request_body(Params0),
|
Params = filter_out_request_body(Params0),
|
||||||
ConfPath = emqx_rule_engine:config_key_path() ++ [Id],
|
ConfPath = emqx_rule_engine:config_key_path() ++ [Id],
|
||||||
case emqx_rule_engine:get_rule(Id) of
|
case emqx_rule_engine:get_rule(Id) of
|
||||||
|
@ -215,6 +218,7 @@ param_path_id() ->
|
||||||
id => Id, reason => Reason}),
|
id => Id, reason => Reason}),
|
||||||
{400, #{code => 'BAD_ARGS', message => ?ERR_BADARGS(Reason)}}
|
{400, #{code => 'BAD_ARGS', message => ?ERR_BADARGS(Reason)}}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
'/rule_test'(post, #{body := Params}) ->
|
'/rule_test'(post, #{body := Params}) ->
|
||||||
|
|
Loading…
Reference in New Issue