diff options
author | ILYA Khlopotov <iilyak@apache.org> | 2019-11-12 16:13:55 +0000 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2020-03-02 12:26:21 -0600 |
commit | 6c11319023b439332052b07b5698bbd45a8f4059 (patch) | |
tree | 67821b9fb8df5178ddd3b201462c3819595cf479 | |
parent | 7eaab664c7ceca470f96d547bd2cb12f7f8aef6a (diff) | |
download | couchdb-6c11319023b439332052b07b5698bbd45a8f4059.tar.gz |
Support regexp based blacklist in config
-rw-r--r-- | src/couch/src/couch_util.erl | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/couch/src/couch_util.erl b/src/couch/src/couch_util.erl index ce0db4306..c56a4f6a5 100644 --- a/src/couch/src/couch_util.erl +++ b/src/couch/src/couch_util.erl @@ -47,15 +47,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$">> ]). @@ -765,10 +765,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. |