You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2020/10/13 16:18:38 UTC

[GitHub] [couchdb] rnewson commented on a change in pull request #3214: Disable custom reduce functions by default

rnewson commented on a change in pull request #3214:
URL: https://github.com/apache/couchdb/pull/3214#discussion_r504084308



##########
File path: src/couch_views/src/couch_views_util.erl
##########
@@ -327,6 +328,33 @@ active_tasks_info(ChangesDone, DbName, DDocId, LastSeq, DBSeq) ->
     }.
 
 
+maybe_disable_custom_reduce_funs(Views) ->
+    case config:get_boolean("couch_views", "custom_reduce_enabled", false) of
+        true ->
+            Views;
+        false ->
+            disable_custom_reduce_funs(Views)
+    end.
+
+
+disable_custom_reduce_funs(Views) ->
+    lists:map(fun(View) ->
+        #mrview{
+            reduce_funs = ReduceFuns
+        } = View,
+        {Builtin, Custom} = lists:partition(fun({_Name, RedSrc}) ->
+            case RedSrc of
+                <<"_", _/binary>> -> true;

Review comment:
       This isn't very strong, it would allow `_foo = 12; fun(keys, values, rereduce) {}` through and I think we'd run that? I think we need to match the whole thing with a regex like `^_[a-z]+]$`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org