Fixed #19866 -- Added security logger and return 400 for SuspiciousOperation.
SuspiciousOperations have been differentiated into subclasses, and are now logged to a 'django.security.*' logger. SuspiciousOperations that reach django.core.handlers.base.BaseHandler will now return a 400 instead of a 500. Thanks to tiwoc for the report, and Carl Meyer and Donald Stufft for review.
This commit is contained in:
6
formtools/exceptions.py
Normal file
6
formtools/exceptions.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.core.exceptions import SuspiciousOperation
|
||||
|
||||
|
||||
class WizardViewCookieModified(SuspiciousOperation):
|
||||
"""Signature of cookie modified"""
|
||||
pass
|
||||
@@ -1,8 +1,8 @@
|
||||
import json
|
||||
|
||||
from django.core.exceptions import SuspiciousOperation
|
||||
from django.core.signing import BadSignature
|
||||
|
||||
from django.contrib.formtools.exceptions import WizardViewCookieModified
|
||||
from django.contrib.formtools.wizard import storage
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class CookieStorage(storage.BaseStorage):
|
||||
except KeyError:
|
||||
data = None
|
||||
except BadSignature:
|
||||
raise SuspiciousOperation('WizardView cookie manipulated')
|
||||
raise WizardViewCookieModified('WizardView cookie manipulated')
|
||||
if data is None:
|
||||
return None
|
||||
return json.loads(data, cls=json.JSONDecoder)
|
||||
|
||||
Reference in New Issue
Block a user