-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #256 from mozilla-services/256_remove_warning
Empty response to OPTIONS request
- Loading branch information
Showing
3 changed files
with
2 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,5 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. | ||
import re | ||
|
||
# Strings and arrays are potentially exploitable | ||
safe_json_re = re.compile(r'\s*[\{tfn\-0-9]'.encode('ascii'), re.MULTILINE) | ||
|
||
|
||
def filter_json_xsrf(response): | ||
"""drops a warning if a service returns potentially exploitable json | ||
""" | ||
if hasattr(response, 'content_type') and response.content_type in ('application/json', 'text/json'): | ||
if safe_json_re.match(response.body) is None: | ||
from cornice import logger | ||
logger.warn("returning a json string or array is a potential " | ||
"security hole, please ensure you really want to do this.") | ||
return response | ||
|
||
|
||
DEFAULT_VALIDATORS = [] | ||
DEFAULT_FILTERS = [filter_json_xsrf, ] | ||
DEFAULT_FILTERS = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[tox] | ||
envlist = py26,py27,py33 | ||
envlist = py26,py27,py34 | ||
|
||
[testenv] | ||
commands = | ||
|