django-debreach-2.0.1/ 0000775 0001750 0001750 00000000000 13547572542 017455 5 ustar lukepomfrey lukepomfrey 0000000 0000000 django-debreach-2.0.1/LICENSE 0000644 0001750 0001750 00000002457 12644500521 020451 0 ustar lukepomfrey lukepomfrey 0000000 0000000 Copyright (c) 2013, Luke Pomfrey
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
django-debreach-2.0.1/MANIFEST.in 0000664 0001750 0001750 00000000334 13342241503 021172 0 ustar lukepomfrey lukepomfrey 0000000 0000000 include LICENSE
include README.rst
include runtests.py
recursive-include debreach *.html *.png *.gif *js *jpg *jpeg *svg *py
recursive-include docs *.rst *.py make.bat Makefile
recursive-include test_project *.py *.html
django-debreach-2.0.1/PKG-INFO 0000664 0001750 0001750 00000001745 13547572542 020561 0 ustar lukepomfrey lukepomfrey 0000000 0000000 Metadata-Version: 1.1
Name: django-debreach
Version: 2.0.1
Summary: Adds middleware to give some added protection against the BREACH attack in Django.
Home-page: http://github.com/lpomfrey/django-debreach
Author: Luke Pomfrey
Author-email: lpomfrey@gmail.com
License: BSD
Description: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Framework :: Django
Classifier: Framework :: Django :: 2.2
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Internet :: WWW/HTTP
django-debreach-2.0.1/README.rst 0000644 0001750 0001750 00000004500 13547562237 021141 0 ustar lukepomfrey lukepomfrey 0000000 0000000 django-debreach
===============
Basic/extra mitigation against the `BREACH attack
Lorem ipsum
''' response = HttpResponse(html, content_type='text/html') request = RequestFactory().get('/') middleware = RandomCommentMiddleware() response = middleware.process_response(request, response) self.assertNotEqual(response.content, html) def test_unicode_characters(self): html = '''{0}
'''.format(''.join(chr(x) for x in range(9999))) response = HttpResponse(html, content_type='text/html') request = RequestFactory().get('/') middleware = RandomCommentMiddleware() response = middleware.process_response(request, response) self.assertNotEqual(force_str(response.content), force_str(html)) def test_exemption(self): html = '''Test body.
''' response = HttpResponse(html) response._random_comment_exempt = True request = RequestFactory().get('/') middleware = RandomCommentMiddleware() response = middleware.process_response(request, response) self.assertEqual(force_str(response.content), html) def test_missing_content_type(self): request = RequestFactory().get('/') response = HttpResponse('') del response['Content-Type'] middleware = RandomCommentMiddleware() processed_response = middleware.process_response(request, response) self.assertEqual(response, processed_response) def test_empty_response_body_ignored(self): request = RequestFactory().get('/') response = HttpResponse('') middleware = RandomCommentMiddleware() processed_response = middleware.process_response(request, response) self.assertEqual(len(processed_response.content), 0) class TestDecorators(TestCase): def test_append_random_comment(self): html = '''Test body.
''' @append_random_comment def test_view(request): return HttpResponse(html) request = RequestFactory().get('/') response = test_view(request) self.assertNotEqual(force_str(response.content), html) self.assertIn('', force_str(response.content)) def test_random_comment_exempt(self): html = '''Test body.
''' @random_comment_exempt def test_view(request): return HttpResponse(html) request = RequestFactory().get('/') response = test_view(request) self.assertTrue(response._random_comment_exempt) @unittest.skipUnless( 'test_project' in os.environ.get('DJANGO_SETTINGS_MODULE', ''), 'Not running in test_project' ) class IntegrationTests(TestCase): def test_adds_comment(self): resp = self.client.get(reverse('home')) self.assertFalse(resp.content.endswith(b'