summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorILYA Khlopotov <iilyak@apache.org>2019-11-12 16:13:55 +0000
committerPaul J. Davis <paul.joseph.davis@gmail.com>2019-11-20 16:58:56 -0600
commit2d3737c898184f9fd3ed33bbb482dab4258ab538 (patch)
tree9d28f1fd7261d311d31a9d21506f5daeb0aafb02
parent706acca183d86342f4f2536f383e3d9cd6fd371d (diff)
downloadcouchdb-2d3737c898184f9fd3ed33bbb482dab4258ab538.tar.gz
Support regexp based blacklist in config
-rw-r--r--src/couch/src/couch_util.erl35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/couch/src/couch_util.erl b/src/couch/src/couch_util.erl
index b3553a5b5..7c64459f7 100644
--- a/src/couch/src/couch_util.erl
+++ b/src/couch/src/couch_util.erl
@@ -46,15 +46,15 @@
-define(FLUSH_MAX_MEM, 10000000).
-define(BLACKLIST_CONFIG_SECTIONS, [
- <<"daemons">>,
- <<"external">>,
- <<"httpd_design_handlers">>,
- <<"httpd_db_handlers">>,
- <<"httpd_global_handlers">>,
- <<"native_query_servers">>,
- <<"os_daemons">>,
- <<"query_servers">>,
- <<"feature_flags">>
+ <<"^daemons$">>,
+ <<"^external$">>,
+ <<"^httpd_design_handlers$">>,
+ <<"^httpd_db_handlers$">>,
+ <<"^httpd_global_handlers$">>,
+ <<"^native_query_servers$">>,
+ <<"^os_daemons$">>,
+ <<"^query_servers$">>,
+ <<"^feature_flags$">>
]).
@@ -751,10 +751,13 @@ unique_monotonic_integer() ->
check_config_blacklist(Section) ->
- case lists:member(Section, ?BLACKLIST_CONFIG_SECTIONS) of
- true ->
- Msg = <<"Config section blacklisted for modification over HTTP API.">>,
- throw({forbidden, Msg});
- _ ->
- ok
- end.
+ lists:foreach(fun(RegExp) ->
+ case re:run(Section, RegExp) of
+ nomatch ->
+ ok;
+ _ ->
+ Msg = <<"Config section blacklisted for modification over HTTP API.">>,
+ throw({forbidden, Msg})
+ end
+ end, ?BLACKLIST_CONFIG_SECTIONS),
+ ok.