couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [1/4] couchdb commit: updated refs/heads/1.4.x to 4decf45
Date Tue, 25 Mar 2014 16:16:34 GMT
Repository: couchdb
Updated Branches:
  refs/heads/1.3.x b68abf9c6 -> 477e8b3fe
  refs/heads/1.4.x afdf9644f -> 4decf45d0
  refs/heads/1.5.x e24ff9218 -> 75e856b16
  refs/heads/master 198bea347 -> 0fb5aa9e6


Configurable upper bound to _uuids count parameter


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/4decf45d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/4decf45d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/4decf45d

Branch: refs/heads/1.4.x
Commit: 4decf45d02a90a099fc8eb685c5871bfebd9521f
Parents: afdf964
Author: Robert Newson <rnewson@apache.org>
Authored: Tue Mar 25 15:02:50 2014 +0000
Committer: Robert Newson <rnewson@apache.org>
Committed: Tue Mar 25 15:09:36 2014 +0000

----------------------------------------------------------------------
 etc/couchdb/default.ini.tpl.in            | 2 ++
 share/www/script/test/uuids.js            | 4 ++++
 src/couchdb/couch_httpd_misc_handlers.erl | 5 +++++
 3 files changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/4decf45d/etc/couchdb/default.ini.tpl.in
----------------------------------------------------------------------
diff --git a/etc/couchdb/default.ini.tpl.in b/etc/couchdb/default.ini.tpl.in
index 43b13a0..2e62e35 100644
--- a/etc/couchdb/default.ini.tpl.in
+++ b/etc/couchdb/default.ini.tpl.in
@@ -212,6 +212,8 @@ algorithm = sequential
 ; The utc_id_suffix value will be appended to uuids generated by the utc_id algorithm.
 ; Replicating instances should have unique utc_id_suffix values to ensure uniqueness of utc_id
ids.
 utc_id_suffix =
+# Maximum number of UUIDs retrievable from /_uuids in a single request
+max_count = 1000
 
 [stats]
 ; rate is in milliseconds

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4decf45d/share/www/script/test/uuids.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/uuids.js b/share/www/script/test/uuids.js
index 6f5d223..0f141a9 100644
--- a/share/www/script/test/uuids.js
+++ b/share/www/script/test/uuids.js
@@ -80,6 +80,10 @@ couchTests.uuids = function(debug) {
     }
   };
 
+  // test max_uuid_count
+  var xhr = CouchDB.request("GET", "/_uuids?count=1001");
+  TEquals(401, xhr.status, "should error when count > max_count");
+
   run_on_modified_server([{
       "section": "uuids",
       "key": "algorithm",

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4decf45d/src/couchdb/couch_httpd_misc_handlers.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl
index 96a05c6..67e3a12 100644
--- a/src/couchdb/couch_httpd_misc_handlers.erl
+++ b/src/couchdb/couch_httpd_misc_handlers.erl
@@ -105,7 +105,12 @@ handle_restart_req(Req) ->
 
 
 handle_uuids_req(#httpd{method='GET'}=Req) ->
+    Max = list_to_integer(couch_config:get("uuids","max","1000")),
     Count = list_to_integer(couch_httpd:qs_value(Req, "count", "1")),
+    case Count > Max of
+        true -> throw({forbidden, <<"count parameter too large">>});
+        false -> ok
+    end,
     UUIDs = [couch_uuids:new() || _ <- lists:seq(1, Count)],
     Etag = couch_httpd:make_etag(UUIDs),
     couch_httpd:etag_respond(Req, Etag, fun() ->


Mime
View raw message