You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by kocolosk <gi...@git.apache.org> on 2015/07/01 03:31:35 UTC
[GitHub] couchdb-couch-mrview pull request: Reject unsupported builtin redu...
GitHub user kocolosk opened a pull request:
https://github.com/apache/couchdb-couch-mrview/pull/20
Reject unsupported builtin reduce functions
We reject bad JS code in design documents, but one thing we haven't done is reject design documents that specify unknown builtin reduce functions. This PR addresses that, and adds a few tests to confirm that we do throw exceptions on these conditions.
COUCHDB-537
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/apache/couchdb-couch-mrview 537-whitelist-builtin-reduce-funs
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/couchdb-couch-mrview/pull/20.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #20
----
commit edb2c8517485a701ac38ebc8c4de2cd4df5a12a0
Author: Adam Kocoloski <ad...@cloudant.com>
Date: 2015-07-01T00:55:05Z
Validate named reduce function against whitelist
COUCHDB-537
commit fc90f2476b6a1dab7b2f0492fdd0a146e0ccf063
Author: Adam Kocoloski <ad...@cloudant.com>
Date: 2015-07-01T01:27:41Z
Add tests for design document validations
COUCHDB-537
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-couch-mrview pull request: Reject unsupported builtin redu...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/couchdb-couch-mrview/pull/20
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-couch-mrview pull request: Reject unsupported builtin redu...
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:
https://github.com/apache/couchdb-couch-mrview/pull/20#issuecomment-117529604
LGFM +1
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-couch-mrview pull request: Reject unsupported builtin redu...
Posted by kocolosk <gi...@git.apache.org>.
Github user kocolosk commented on a diff in the pull request:
https://github.com/apache/couchdb-couch-mrview/pull/20#discussion_r33641584
--- Diff: test/couch_mrview_ddoc_validation_tests.erl ---
@@ -0,0 +1,78 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+% http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_mrview_ddoc_validation_tests).
+
+-include_lib("couch/include/couch_eunit.hrl").
+-include_lib("couch/include/couch_db.hrl").
+
+setup() ->
+ {ok, Db} = couch_mrview_test_util:init_db(?tempdb(), map),
+ Db.
+
+teardown(Db) ->
+ couch_db:close(Db),
+ couch_server:delete(Db#db.name, [?ADMIN_CTX]),
+ ok.
+
+ddoc_validation_test_() ->
+ {
+ "ddoc validation tests",
+ {
+ setup,
+ fun test_util:start_couch/0, fun test_util:stop_couch/1,
+ {
+ foreach,
+ fun setup/0, fun teardown/1,
+ [
+ fun should_reject_invalid_js_map/1,
+ fun should_reject_invalid_js_reduce/1,
+ fun should_reject_invalid_builtin_reduce/1
+ ]
+ }
+ }
+ }.
+
+should_reject_invalid_js_map(Db) ->
+ Doc = couch_doc:from_json_obj({[
+ {<<"_id">>, <<"_design/should_reject_invalid_js_map">>},
+ {<<"views">>, {[
+ {<<"foo">>, {[
+ {<<"map">>, <<"function(doc) }{">>}
+ ]}}
+ ]}}
+ ]}),
+ ?_assertThrow({compilation_error, _}, couch_db:update_doc(Db, Doc, [])).
+
+should_reject_invalid_js_reduce(Db) ->
+ Doc = couch_doc:from_json_obj({[
+ {<<"_id">>, <<"_design/should_reject_invalid_js_map">>},
--- End diff --
Oops, missed the name here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---