summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-02-21 11:46:10 -0500
committerRob Crittenden <rcritten@redhat.com>2011-02-22 09:09:46 -0500
commit79d22f8341026450ba7ca564e24812c9351c7e70 (patch)
treee5c6e97eed8397aa457ee4082c274ea1511dd167
parent6e7815a30e6897967b3c7e50f98f23c8a89c3b03 (diff)
downloadfreeipa-79d22f8341026450ba7ca564e24812c9351c7e70.zip
freeipa-79d22f8341026450ba7ca564e24812c9351c7e70.tar.gz
freeipa-79d22f8341026450ba7ca564e24812c9351c7e70.tar.xz
Set hard limit on number of commands in batch request to 256.
ticket 984
-rw-r--r--ipalib/errors.py17
-rw-r--r--ipalib/plugins/batch.py2
2 files changed, 19 insertions, 0 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py
index f48ad55..6883cbd 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -1471,6 +1471,23 @@ class NotRegisteredError(ExecutionError):
format = _('Not registered yet')
+class BatchRequestLimitError(ExecutionError):
+ """
+ **4307** Raised when a batch request contains too many commands
+
+ For example:
+ >>> raise BatchRequestLimitError(limit=128)
+ Traceback (most recent call last):
+ ...
+ BatchRequestLimitError: Too many commands in request, limit is 128
+
+ """
+
+ errno = 4307
+ format = _('Too many commands in request, limit is %(limit)s')
+
+
+
##############################################################################
# 5000 - 5999: Generic errors
diff --git a/ipalib/plugins/batch.py b/ipalib/plugins/batch.py
index a590779..5455340 100644
--- a/ipalib/plugins/batch.py
+++ b/ipalib/plugins/batch.py
@@ -80,6 +80,8 @@ class batch(Command):
def execute(self, *args, **options):
results=[]
+ if len(args[0]) > 256:
+ raise errors.BatchRequestLimitError(limit=256)
for arg in args[0]:
try:
a = arg['params'][0]