Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalware-1.9.git;a=commitdiff;h=0c7a8720cc05356d225f94460935ab99ee14a9d9
commit 0c7a8720cc05356d225f94460935ab99ee14a9d9 Author: kikadf <[email protected]> Date: Tue Apr 22 19:30:48 2014 +0200 django-1.5.2-2arcturus1-x86_64 * Fix CVE-2014-0472, CVE-2014-0473, CVE-2014-0474 diff --git a/source/devel-extra/django/CVE-2014-0472.patch b/source/devel-extra/django/CVE-2014-0472.patch new file mode 100644 index 0000000..a967ad2 --- /dev/null +++ b/source/devel-extra/django/CVE-2014-0472.patch @@ -0,0 +1,148 @@ +Description: fix unexpected code execution using reverse() +Origin: provided by upstream +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/python-django/+bug/1309779 + +Index: python-django-1.5.4/django/core/urlresolvers.py +=================================================================== +--- python-django-1.5.4.orig/django/core/urlresolvers.py 2013-09-15 02:28:02.000000000 -0400 ++++ python-django-1.5.4/django/core/urlresolvers.py 2014-04-19 09:04:48.762171513 -0400 +@@ -244,6 +244,10 @@ + self._reverse_dict = {} + self._namespace_dict = {} + self._app_dict = {} ++ # set of dotted paths to all functions and classes that are used in ++ # urlpatterns ++ self._callback_strs = set() ++ self._populated = False + + def __repr__(self): + if isinstance(self.urlconf_name, list) and len(self.urlconf_name): +@@ -261,6 +265,15 @@ + apps = {} + language_code = get_language() + for pattern in reversed(self.url_patterns): ++ if hasattr(pattern, '_callback_str'): ++ self._callback_strs.add(pattern._callback_str) ++ elif hasattr(pattern, '_callback'): ++ callback = pattern._callback ++ if not hasattr(callback, '__name__'): ++ lookup_str = callback.__module__ + "." + callback.__class__.__name__ ++ else: ++ lookup_str = callback.__module__ + "." + callback.__name__ ++ self._callback_strs.add(lookup_str) + p_pattern = pattern.regex.pattern + if p_pattern.startswith('^'): + p_pattern = p_pattern[1:] +@@ -281,6 +294,7 @@ + namespaces[namespace] = (p_pattern + prefix, sub_pattern) + for app_name, namespace_list in pattern.app_dict.items(): + apps.setdefault(app_name, []).extend(namespace_list) ++ self._callback_strs.update(pattern._callback_strs) + else: + bits = normalize(p_pattern) + lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args)) +@@ -289,6 +303,7 @@ + self._reverse_dict[language_code] = lookups + self._namespace_dict[language_code] = namespaces + self._app_dict[language_code] = apps ++ self._populated = True + + @property + def reverse_dict(self): +@@ -375,8 +390,13 @@ + def _reverse_with_prefix(self, lookup_view, _prefix, *args, **kwargs): + if args and kwargs: + raise ValueError("Don't mix *args and **kwargs in call to reverse()!") ++ ++ if not self._populated: ++ self._populate() ++ + try: +- lookup_view = get_callable(lookup_view, True) ++ if lookup_view in self._callback_strs: ++ lookup_view = get_callable(lookup_view, True) + except (ImportError, AttributeError) as e: + raise NoReverseMatch("Error importing '%s': %s." % (lookup_view, e)) + possibilities = self.reverse_dict.getlist(lookup_view) +Index: python-django-1.5.4/tests/regressiontests/urlpatterns_reverse/nonimported_module.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ python-django-1.5.4/tests/regressiontests/urlpatterns_reverse/nonimported_module.py 2014-04-19 09:04:48.762171513 -0400 +@@ -0,0 +1,3 @@ ++def view(request): ++ """Stub view""" ++ pass +Index: python-django-1.5.4/tests/regressiontests/urlpatterns_reverse/tests.py +=================================================================== +--- python-django-1.5.4.orig/tests/regressiontests/urlpatterns_reverse/tests.py 2013-09-15 02:28:02.000000000 -0400 ++++ python-django-1.5.4/tests/regressiontests/urlpatterns_reverse/tests.py 2014-04-19 09:04:48.762171513 -0400 +@@ -1,8 +1,11 @@ ++# -*- coding: utf-8 -*- + """ + Unit tests for reverse URL lookups. + """ + from __future__ import absolute_import, unicode_literals + ++import sys ++ + from django.conf import settings + from django.contrib.auth.models import User + from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist +@@ -290,6 +293,25 @@ + self.assertEqual(res['Location'], '/foo/') + res = redirect('http://example.com/') + self.assertEqual(res['Location'], 'http://example.com/') ++ # Assert that we can redirect using UTF-8 strings ++ res = redirect('/æøå/abc/') ++ self.assertEqual(res['Location'], '/%C3%A6%C3%B8%C3%A5/abc/') ++ # Assert that no imports are attempted when dealing with a relative path ++ # (previously, the below would resolve in a UnicodeEncodeError from __import__ ) ++ res = redirect('/æøå.abc/') ++ self.assertEqual(res['Location'], '/%C3%A6%C3%B8%C3%A5.abc/') ++ res = redirect('os.path') ++ self.assertEqual(res['Location'], 'os.path') ++ ++ def test_no_illegal_imports(self): ++ # modules that are not listed in urlpatterns should not be importable ++ redirect("urlpatterns_reverse.nonimported_module.view") ++ self.assertNotIn("urlpatterns_reverse.nonimported_module", sys.modules) ++ ++ def test_reverse_by_path_nested(self): ++ # Views that are added to urlpatterns using include() should be ++ # reversable by doted path. ++ self.assertEqual(reverse('regressiontests.urlpatterns_reverse.views.nested_view'), '/includes/nested_path/') + + def test_redirect_view_object(self): + from .views import absolute_kwargs_view +@@ -559,4 +581,3 @@ + # swallow it. + self.assertRaises(AttributeError, get_callable, + 'regressiontests.urlpatterns_reverse.views_broken.i_am_broken') +- +Index: python-django-1.5.4/tests/regressiontests/urlpatterns_reverse/urls.py +=================================================================== +--- python-django-1.5.4.orig/tests/regressiontests/urlpatterns_reverse/urls.py 2013-09-15 02:21:17.000000000 -0400 ++++ python-django-1.5.4/tests/regressiontests/urlpatterns_reverse/urls.py 2014-04-19 09:04:48.762171513 -0400 +@@ -7,6 +7,7 @@ + + other_patterns = patterns('', + url(r'non_path_include/$', empty_view, name='non_path_include'), ++ url(r'nested_path/$', 'regressiontests.urlpatterns_reverse.views.nested_view'), + ) + + urlpatterns = patterns('', +Index: python-django-1.5.4/tests/regressiontests/urlpatterns_reverse/views.py +=================================================================== +--- python-django-1.5.4.orig/tests/regressiontests/urlpatterns_reverse/views.py 2013-09-15 02:28:02.000000000 -0400 ++++ python-django-1.5.4/tests/regressiontests/urlpatterns_reverse/views.py 2014-04-19 09:04:48.762171513 -0400 +@@ -16,6 +16,10 @@ + def defaults_view(request, arg1, arg2): + pass + ++def nested_view(request): ++ pass ++ ++ + def erroneous_view(request): + import non_existent + diff --git a/source/devel-extra/django/CVE-2014-0473.patch b/source/devel-extra/django/CVE-2014-0473.patch new file mode 100644 index 0000000..6c5fa99 --- /dev/null +++ b/source/devel-extra/django/CVE-2014-0473.patch @@ -0,0 +1,92 @@ +Description: fix caching of anonymous pages could reveal CSRF token +Origin: commit d96e13553a37843a58be7440f159258c2a57094f +Author: Aymeric Augustin <[email protected]> +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/python-django/+bug/1309782 + +Index: python-django-1.5.4/django/middleware/cache.py +=================================================================== +--- python-django-1.5.4.orig/django/middleware/cache.py 2013-09-15 02:28:02.000000000 -0400 ++++ python-django-1.5.4/django/middleware/cache.py 2014-04-19 09:06:07.254172785 -0400 +@@ -50,7 +50,8 @@ + + from django.conf import settings + from django.core.cache import get_cache, DEFAULT_CACHE_ALIAS +-from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers, get_max_age ++from django.utils.cache import (get_cache_key, get_max_age, has_vary_header, ++ learn_cache_key, patch_response_headers) + + + class UpdateCacheMiddleware(object): +@@ -93,8 +94,15 @@ + if not self._should_update_cache(request, response): + # We don't need to update the cache, just return. + return response ++ + if response.streaming or response.status_code != 200: + return response ++ ++ # Don't cache responses that set a user-specific (and maybe security ++ # sensitive) cookie in response to a cookie-less request. ++ if not request.COOKIES and response.cookies and has_vary_header(response, 'Cookie'): ++ return response ++ + # Try to get the timeout from the "max-age" section of the "Cache- + # Control" header before reverting to using the default cache_timeout + # length. +Index: python-django-1.5.4/tests/regressiontests/cache/tests.py +=================================================================== +--- python-django-1.5.4.orig/tests/regressiontests/cache/tests.py 2013-09-15 02:28:02.000000000 -0400 ++++ python-django-1.5.4/tests/regressiontests/cache/tests.py 2014-04-19 09:06:07.258172785 -0400 +@@ -18,11 +18,13 @@ + from django.core.cache import get_cache + from django.core.cache.backends.base import (CacheKeyWarning, + InvalidCacheBackendError) ++from django.core.context_processors import csrf + from django.db import router + from django.http import (HttpResponse, HttpRequest, StreamingHttpResponse, + QueryDict) + from django.middleware.cache import (FetchFromCacheMiddleware, + UpdateCacheMiddleware, CacheMiddleware) ++from django.middleware.csrf import CsrfViewMiddleware + from django.template import Template + from django.template.response import TemplateResponse + from django.test import TestCase, TransactionTestCase, RequestFactory +@@ -1456,6 +1458,10 @@ + return HttpResponse('Hello World %s' % value) + + ++def csrf_view(request): ++ return HttpResponse(csrf(request)['csrf_token']) ++ ++ + @override_settings( + CACHE_MIDDLEWARE_ALIAS='other', + CACHE_MIDDLEWARE_KEY_PREFIX='middlewareprefix', +@@ -1696,6 +1702,27 @@ + response = other_with_timeout_view(request, '18') + self.assertEqual(response.content, b'Hello World 18') + ++ def test_sensitive_cookie_not_cached(self): ++ """ ++ Django must prevent caching of responses that set a user-specific (and ++ maybe security sensitive) cookie in response to a cookie-less request. ++ """ ++ csrf_middleware = CsrfViewMiddleware() ++ cache_middleware = CacheMiddleware() ++ ++ request = self.factory.get('/view/') ++ self.assertIsNone(cache_middleware.process_request(request)) ++ ++ csrf_middleware.process_view(request, csrf_view, (), {}) ++ ++ response = csrf_view(request) ++ ++ response = csrf_middleware.process_response(request, response) ++ response = cache_middleware.process_response(request, response) ++ ++ # Inserting a CSRF cookie in a cookie-less request prevented caching. ++ self.assertIsNone(cache_middleware.process_request(request)) ++ + + @override_settings( + CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix', diff --git a/source/devel-extra/django/CVE-2014-0474.patch b/source/devel-extra/django/CVE-2014-0474.patch new file mode 100644 index 0000000..db53b21 --- /dev/null +++ b/source/devel-extra/django/CVE-2014-0474.patch @@ -0,0 +1,251 @@ +Description: fix MySQL typecasting issue +Origin: provided by upstream +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/python-django/+bug/1309784 + +Index: python-django-1.5.4/django/db/models/fields/__init__.py +=================================================================== +--- python-django-1.5.4.orig/django/db/models/fields/__init__.py 2013-09-15 02:28:02.000000000 -0400 ++++ python-django-1.5.4/django/db/models/fields/__init__.py 2014-04-19 09:06:37.378173274 -0400 +@@ -934,6 +934,12 @@ + kwargs['max_length'] = kwargs.get('max_length', 100) + Field.__init__(self, verbose_name, name, **kwargs) + ++ def get_prep_value(self, value): ++ value = super(FilePathField, self).get_prep_value(value) ++ if value is None: ++ return None ++ return six.text_type(value) ++ + def formfield(self, **kwargs): + defaults = { + 'path': self.path, +@@ -1035,6 +1041,12 @@ + kwargs['max_length'] = 15 + Field.__init__(self, *args, **kwargs) + ++ def get_prep_value(self, value): ++ value = super(IPAddressField, self).get_prep_value(value) ++ if value is None: ++ return None ++ return six.text_type(value) ++ + def get_internal_type(self): + return "IPAddressField" + +@@ -1072,12 +1084,14 @@ + return value or None + + def get_prep_value(self, value): ++ if value is None: ++ return value + if value and ':' in value: + try: + return clean_ipv6_address(value, self.unpack_ipv4) + except exceptions.ValidationError: + pass +- return value ++ return six.text_type(value) + + def formfield(self, **kwargs): + defaults = {'form_class': forms.GenericIPAddressField} +Index: python-django-1.5.4/docs/howto/custom-model-fields.txt +=================================================================== +--- python-django-1.5.4.orig/docs/howto/custom-model-fields.txt 2013-09-15 02:28:02.000000000 -0400 ++++ python-django-1.5.4/docs/howto/custom-model-fields.txt 2014-04-19 09:06:37.378173274 -0400 +@@ -501,6 +501,16 @@ + return ''.join([''.join(l) for l in (value.north, + value.east, value.south, value.west)]) + ++.. warning:: ++ ++ If your custom field uses the ``CHAR``, ``VARCHAR`` or ``TEXT`` ++ types for MySQL, you must make sure that :meth:`.get_prep_value` ++ always returns a string type. MySQL performs flexible and unexpected ++ matching when a query is performed on these types and the provided ++ value is an integer, which can cause queries to include unexpected ++ objects in their results. This problem cannot occur if you always ++ return a string type from :meth:`.get_prep_value`. ++ + Converting query values to database values + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Index: python-django-1.5.4/docs/ref/databases.txt +=================================================================== +--- python-django-1.5.4.orig/docs/ref/databases.txt 2013-09-15 02:28:02.000000000 -0400 ++++ python-django-1.5.4/docs/ref/databases.txt 2014-04-19 09:06:37.378173274 -0400 +@@ -429,6 +429,22 @@ + statement. If ``select_for_update()`` is used with ``nowait=True`` then a + ``DatabaseError`` will be raised. + ++Automatic typecasting can cause unexpected results ++-------------------------------------------------- ++ ++When performing a query on a string type, but with an integer value, MySQL will ++coerce the types of all values in the table to an integer before performing the ++comparison. If your table contains the values ``'abc'``, ``'def'`` and you ++query for ``WHERE mycolumn=0``, both rows will match. Similarly, ``WHERE mycolumn=1`` ++will match the value ``'abc1'``. Therefore, string type fields included in Django ++will always cast the value to a string before using it in a query. ++ ++If you implement custom model fields that inherit from :class:`~django.db.models.Field` ++directly, are overriding :meth:`~django.db.models.Field.get_prep_value`, or use ++:meth:`extra() <django.db.models.query.QuerySet.extra>` or ++:meth:`raw() <django.db.models.Manager.raw>`, you should ensure that you ++perform the appropriate typecasting. ++ + .. _sqlite-notes: + + SQLite notes +Index: python-django-1.5.4/docs/ref/models/querysets.txt +=================================================================== +--- python-django-1.5.4.orig/docs/ref/models/querysets.txt 2013-09-15 02:28:02.000000000 -0400 ++++ python-django-1.5.4/docs/ref/models/querysets.txt 2014-04-19 09:06:37.378173274 -0400 +@@ -1068,6 +1068,16 @@ + + Entry.objects.extra(where=['headline=%s'], params=['Lennon']) + ++.. warning:: ++ ++ If you are performing queries on MySQL, note that MySQL's silent type coercion ++ may cause unexpected results when mixing types. If you query on a string ++ type column, but with an integer value, MySQL will coerce the types of all values ++ in the table to an integer before performing the comparison. For example, if your ++ table contains the values ``'abc'``, ``'def'`` and you query for ``WHERE mycolumn=0``, ++ both rows will match. To prevent this, perform the correct typecasting ++ before using the value in a query. ++ + defer + ~~~~~ + +Index: python-django-1.5.4/docs/topics/db/sql.txt +=================================================================== +--- python-django-1.5.4.orig/docs/topics/db/sql.txt 2013-09-15 02:28:02.000000000 -0400 ++++ python-django-1.5.4/docs/topics/db/sql.txt 2014-04-19 09:06:37.378173274 -0400 +@@ -66,6 +66,16 @@ + database, but does nothing to enforce that. If the query does not + return rows, a (possibly cryptic) error will result. + ++.. warning:: ++ ++ If you are performing queries on MySQL, note that MySQL's silent type coercion ++ may cause unexpected results when mixing types. If you query on a string ++ type column, but with an integer value, MySQL will coerce the types of all values ++ in the table to an integer before performing the comparison. For example, if your ++ table contains the values ``'abc'``, ``'def'`` and you query for ``WHERE mycolumn=0``, ++ both rows will match. To prevent this, perform the correct typecasting ++ before using the value in a query. ++ + Mapping query fields to model fields + ------------------------------------ + +Index: python-django-1.5.4/tests/regressiontests/model_fields/tests.py +=================================================================== +--- python-django-1.5.4.orig/tests/regressiontests/model_fields/tests.py 2013-09-15 02:28:02.000000000 -0400 ++++ python-django-1.5.4/tests/regressiontests/model_fields/tests.py 2014-04-19 09:06:37.378173274 -0400 +@@ -6,8 +6,15 @@ + from django import test + from django import forms + from django.core.exceptions import ValidationError ++from django.db.models.fields import ( ++ AutoField, BigIntegerField, BooleanField, CharField, ++ CommaSeparatedIntegerField, DateField, DateTimeField, DecimalField, ++ EmailField, FilePathField, FloatField, IntegerField, IPAddressField, ++ GenericIPAddressField, NullBooleanField, PositiveIntegerField, ++ PositiveSmallIntegerField, SlugField, SmallIntegerField, TextField, ++ TimeField, URLField) + from django.db import models +-from django.db.models.fields.files import FieldFile ++from django.db.models.fields.files import FileField, ImageField, FieldFile + from django.utils import six + from django.utils import unittest + +@@ -414,3 +421,89 @@ + field = d._meta.get_field('myfile') + field.save_form_data(d, 'else.txt') + self.assertEqual(d.myfile, 'else.txt') ++ ++ ++class PrepValueTest(test.TestCase): ++ def test_AutoField(self): ++ self.assertIsInstance(AutoField(primary_key=True).get_prep_value(1), int) ++ ++ @unittest.skipIf(six.PY3, "Python 3 has no `long` type.") ++ def test_BigIntegerField(self): ++ self.assertIsInstance(BigIntegerField().get_prep_value(long(9999999999999999999)), long) ++ ++ def test_BooleanField(self): ++ self.assertIsInstance(BooleanField().get_prep_value(True), bool) ++ ++ def test_CharField(self): ++ self.assertIsInstance(CharField().get_prep_value(''), six.text_type) ++ self.assertIsInstance(CharField().get_prep_value(0), six.text_type) ++ ++ def test_CommaSeparatedIntegerField(self): ++ self.assertIsInstance(CommaSeparatedIntegerField().get_prep_value('1,2'), six.text_type) ++ self.assertIsInstance(CommaSeparatedIntegerField().get_prep_value(0), six.text_type) ++ ++ def test_DateField(self): ++ self.assertIsInstance(DateField().get_prep_value(datetime.date.today()), datetime.date) ++ ++ def test_DateTimeField(self): ++ self.assertIsInstance(DateTimeField().get_prep_value(datetime.datetime.now()), datetime.datetime) ++ ++ def test_DecimalField(self): ++ self.assertIsInstance(DecimalField().get_prep_value(Decimal('1.2')), Decimal) ++ ++ def test_EmailField(self): ++ self.assertIsInstance(EmailField().get_prep_value('[email protected]'), six.text_type) ++ ++ def test_FileField(self): ++ self.assertIsInstance(FileField().get_prep_value('filename.ext'), six.text_type) ++ self.assertIsInstance(FileField().get_prep_value(0), six.text_type) ++ ++ def test_FilePathField(self): ++ self.assertIsInstance(FilePathField().get_prep_value('tests.py'), six.text_type) ++ self.assertIsInstance(FilePathField().get_prep_value(0), six.text_type) ++ ++ def test_FloatField(self): ++ self.assertIsInstance(FloatField().get_prep_value(1.2), float) ++ ++ def test_ImageField(self): ++ self.assertIsInstance(ImageField().get_prep_value('filename.ext'), six.text_type) ++ ++ def test_IntegerField(self): ++ self.assertIsInstance(IntegerField().get_prep_value(1), int) ++ ++ def test_IPAddressField(self): ++ self.assertIsInstance(IPAddressField().get_prep_value('127.0.0.1'), six.text_type) ++ self.assertIsInstance(IPAddressField().get_prep_value(0), six.text_type) ++ ++ def test_GenericIPAddressField(self): ++ self.assertIsInstance(GenericIPAddressField().get_prep_value('127.0.0.1'), six.text_type) ++ self.assertIsInstance(GenericIPAddressField().get_prep_value(0), six.text_type) ++ ++ def test_NullBooleanField(self): ++ self.assertIsInstance(NullBooleanField().get_prep_value(True), bool) ++ ++ def test_PositiveIntegerField(self): ++ self.assertIsInstance(PositiveIntegerField().get_prep_value(1), int) ++ ++ def test_PositiveSmallIntegerField(self): ++ self.assertIsInstance(PositiveSmallIntegerField().get_prep_value(1), int) ++ ++ def test_SlugField(self): ++ self.assertIsInstance(SlugField().get_prep_value('slug'), six.text_type) ++ self.assertIsInstance(SlugField().get_prep_value(0), six.text_type) ++ ++ def test_SmallIntegerField(self): ++ self.assertIsInstance(SmallIntegerField().get_prep_value(1), int) ++ ++ def test_TextField(self): ++ self.assertIsInstance(TextField().get_prep_value('Abc'), six.text_type) ++ self.assertIsInstance(TextField().get_prep_value(0), six.text_type) ++ ++ def test_TimeField(self): ++ self.assertIsInstance( ++ TimeField().get_prep_value(datetime.datetime.now().time()), ++ datetime.time) ++ ++ def test_URLField(self): ++ self.assertIsInstance(URLField().get_prep_value('http://domain.com'), six.text_type) ++ diff --git a/source/devel-extra/django/FrugalBuild b/source/devel-extra/django/FrugalBuild index bcf7db7..05e60d1 100644 --- a/source/devel-extra/django/FrugalBuild +++ b/source/devel-extra/django/FrugalBuild @@ -7,7 +7,7 @@ pkgname=django _F_archive_name=Django pkgver=1.5.2 _branch=1.5 -pkgrel=1 +pkgrel=2arcturus1 pkgdesc="Django is a Python web framework" url="https://www.djangoproject.com" depends=('python') @@ -17,3 +17,13 @@ archs=('i686' 'x86_64') up2date="Fwcat $url/download|lynx -dump -stdin|grep -m1 .tar.gz|sed 's/.*Django-\(.*\).tar.gz.*/\1/'" source=($url/m/releases/$_branch/$_F_archive_name-$pkgver.tar.gz) sha1sums=('7137d32505727b057c77b025c3a0355c131de1af') + + +# FSA fix *** +source=(${source[@]} CVE-2014-0472.patch CVE-2014-0473.patch CVE-2014-0474.patch) +sha1sums=(${sha1sums[@]} '5ef94b51e0d3bf4ed93411266a738ea99fca7eb8' \ + '47d506fa7cddd4994ea47652e9fda7d35de882d4' \ + '1a5b72cb58fdae94132403f53c7a15e210826c59') +# *********** + +
_______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
