components/python/django/patches/CVE-2016-2513.patch
author Devjani Ray <devjani.ray@oracle.com>
Fri, 20 May 2016 17:42:29 -0400
branchs11u3-sru
changeset 6035 c9748fcc32de
permissions -rw-r--r--
PSARC 2015/535 OpenStack service updates for Kilo PSARC 2015/458 aioeventlet - asyncio event loop scheduling callbacks in eventlet PSARC 2015/460 msgpack - C/Python bindings for MessagePack (de)serializer data PSARC 2015/466 openstackclient - OpenStack Command-line Client PSARC 2015/467 oslo.versionedobjects - Oslo Versioned Objects library PSARC 2015/468 pint - A physical quantities module PSARC 2015/469 pysaml2 - A pure Python implementation of SAML2 PSARC 2015/471 semantic_version - A library implementing the 'SemVer' scheme PSARC 2015/472 testresources - PyUnit extension for managing expensive test resources PSARC 2015/473 testscenarios - Extensions to Python unittest to support scenarios PSARC 2015/474 trollius - Port of the Tulip project (asyncio module, PEP 3156) on Python 2 PSARC 2015/475 urllib3 - HTTP library with thread-safe connection pooling, file post, and more PSARC 2015/520 oslo.concurrency - Oslo Concurrency library PSARC 2015/521 oslo.log - Oslo Logging Configuration library PSARC 2015/529 oslo.policy - Oslo Policy library PSARC 2015/530 psutil - Python system and process utilities PSARC 2015/538 fixtures - Python module to support reusable state for writing clean tests PSARC 2015/539 sqlparse - An SQL parser module for Python PSARC 2016/017 extras - Useful extra utilities for Python PSARC 2016/018 linecache2 - Port of the standard linecache module PSARC 2016/019 python-mimeparse - Basic functions for parsing mime-types PSARC 2016/020 testtools - Extensions to the Python unit testing framework PSARC 2016/021 traceback2 - Port of the standard traceback module PSARC 2016/014 OpenStack Cinder NFS driver for Solaris PSARC/2016/010 cloudbase-init: Portable cloud image initialization PSARC/2016/130 Solaris OpenStack Puppet Extensions PSARC/2016/172 Making OpenStack Nova's image cache sharable PSARC/2016/001 OpenStack Puppet Modules PSARC/2016/016 Rename/Refactor Puppet and Puppet Module Packages PSARC/2015/368 Common Puppet Modules PSARC 2015/357 OpenStack Nova support for kernel zone suspend/resume 22384068 OpenStack service updates for Kilo (Umbrella) 23205460 Fix for 23192887 breaks Juno to Kilo upgrade with instances and floating IPs 23192887 Upgrade from Juno to Kilo fails (neutron-upgrade) due to typo 22878181 Neutron database tables not upgraded properly from Juno to Kilo schema 22935140 Kilo upgrade adds deprecated settings for rabbit and qpid 22935039 Kilo upgrade conf file migration errors 23027746 Metadata access broken with too many networks 23040216 extra zfssa_ prefix in the zfssa_iscsi.pp backend manifest 22992961 Update saz-memcached to 2.8.1 22992956 Update puppetlabs-stdlib to 4.11.0 22992951 Update puppetlabs-ntp to 4.1.2 22992946 Update puppetlabs-mysql to 3.6.2 22992926 Update puppetlabs-apache to 1.8.1 22992933 Update puppetlabs-inifile to 1.4.3 22999085 apache puppet module doesn't support ssl on Solaris 22985076 neutron_network provider always sets --shared on new networks 22813139 add zfssa cinder puppet modules 22902222 add NFS cinder puppet modules 22918553 update vpnaas and l3 agent puppet modules 22902853 Neutron/VPNaaS needs a workaround for 22902761 22827759 nova-compute still trips over itself when rad:local restarts 20990774 nova image cache bloats clone archives to godzilla size 22750945 Revert resize same host branded zones results in error status 18733958 nova tried to create x86 instance on SPARC 22220227 failure to apply zonecfg in attach_volume can leave debris in zonecfg 22935198 puppetlabs-mysql should define basedir in params.pp 22911268 Update puppetlabs-rabbitmq to 5.3.1 22852949 problem in PYTHON-MOD/DJANGO 22852962 problem in PYTHON-MOD/DJANGO 22819808 target_provision_state should not be set to AVAILABLE 22491714 Request to integrate OpenStack Puppet modules 22713569 nova-conductor doesn't handle RPC timeout during live-migration well 22695176 Miscellaneous package cleanup for Kilo 22694904 Some of the OpenStack patches can be cleaned up 22694680 Dependencies in several OpenStack service packages can be improved 22694592 Several configuration files should be more aligned with the upstream 22575858 problem in SERVICE/SWIFT 22047789 puppet package name and dependencies are confusing 22664785 Puppet module files should be owned by puppet 21460057 Add cloudbase-init to Solaris 21974208 The Python module msgpack should be added to Userland 22010630 The Python trollius module should be added to Userland 22011755 The Python module pint should be added to Userland 22012256 The Python aioeventlet module should be added to Userland 22012282 The Python oslo.versionedobjects module should be added to Userland 22012317 The Python semantic_version module should be added to Userland 22012321 The Python testresources module should be added to Userland 22012329 The Python testscenarios module should be added to Userland 22012336 The Python urllib3 module should be added to Userland 22012343 The Python openstackclient module should be added to Userland 22299389 The Python oslo.concurrency module should be added to Userland 22299409 The Python oslo.log module should be added to Userland 22299418 The Python oslo.policy module should be added to Userland 22299469 The Python psutil module should be added to Userland 22337793 The Python sqlparse module should be added to Userland 22338325 The Python fixtures module should be added to Userland 22535728 The Python testtools module should be added to Userland 22535739 The Python extras module should be added to Userland 22535748 The Python linecache2 module should be added to Userland 22535753 The Python traceback2 module should be added to Userland 22535760 The Python python-mimeparse module should be added to Userland 18961001 Image filtering does not function as expected 21678935 NFS for Cinder in Solaris OpenStack 22548630 derived manifest should not enforce presence of global when installing from UAR 22629795 problem in SERVICE/KEYSTONE 22151922 zones_suspend_path needs update based on post-PSARC discussion 21660603 passlib dependency needs to be added to Nova 22188197 puppetlabs-rabbitmq needs a patch to handle rabbitmqadmin 21756542 problem in SERVICE/SWIFT 21978756 addrconf addresses must be created for stateless and slaac Neutron subnets 21978743 ndpd.conf entries are incorrectly formatted for IPv6 subnets 21919000 neutron-dhcp-agent and neutron-server have timing issues 21918991 database times out when attempting various actions 21682493 Neutron fails due to mysql transaction locks when creating multiple instances 22024767 Remove annoying "Arguments dropped when creating context" logging 21691386 Request to integrate common puppet modules into Userland 21630128 Neutron needs to support updating subnet DNS configuration 21761279 Driver erroneously includes trailing space in zone.install() arguments 21438537 After update, openstack/keystone/keystone-token-flush not running 21630538 Nova driver should support suspend/resume 21542088 VM's display_name is used instead of hostname to set the hostname for VM 19774239 Nova should support setting the Admin Password 21439855 Console SMF instance remains after nova instance is deleted 21348400 Issues encountered via unit testing 21341088 Parsing manifest/profiles fails if multiple criteria present 21303465 edit image window has no ZFS disk format option 21091598 ceilometerclient's Makefile needs to point to its own PROJECT_URL 21164329 saharaclient COMPONENT_BUGDB points to the wrong subcomponent 20431382 keystone should include a periodic token cleanup job 21299660 enable no-gateway check box now that we support it 21135855 Enable gateway-less external networks 20230409 remove _get_zone_auto_install_state from driver.py 21022556 optional dependencies on rabbitmq need work in OpenStack services 22568587 heat denial of service through template-validate 22157556 RabbitMQ Warning: Mochiweb enabled and Erlang version 17
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6035
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
     1
Patches taken from:
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
     2
https://github.com/django/django/commit/f4e6e02f7713a6924d16540be279909ff4091eb6
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
     3
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
     4
This is fixed in Django 1.8.11 and 1.9.4
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
     5
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
     6
--- Django-1.4.22/django/contrib/auth/hashers.py.orig    2016-03-09 20:03:40.232546554 -0800
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
     7
+++ Django-1.4.22/django/contrib/auth/hashers.py  2016-03-09 20:12:45.684315031 -0800
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
     8
@@ -1,4 +1,5 @@
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
     9
 import hashlib
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    10
+import warnings
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    11
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    12
 from django.conf import settings
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    13
 from django.utils import importlib
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    14
@@ -47,8 +48,17 @@ def check_password(password, encoded, se
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    15
         algorithm = encoded.split('$', 1)[0]
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    16
         hasher = get_hasher(algorithm)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    17
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    18
-    must_update = hasher.algorithm != preferred.algorithm
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    19
+    hasher_changed = hasher.algorithm != preferred.algorithm
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    20
+    must_update = hasher_changed or preferred.must_update(encoded)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    21
     is_correct = hasher.verify(password, encoded)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    22
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    23
+    # If the hasher didn't change (we don't protect against enumeration if it
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    24
+    # does) and the password should get updated, try to close the timing gap
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    25
+    # between the work factor of the current encoded password and the default
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    26
+    # work factor.
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    27
+    if not is_correct and not hasher_changed and must_update:
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    28
+        hasher.harden_runtime(password, encoded)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    29
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    30
     if setter and is_correct and must_update:
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    31
         setter(raw_password)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    32
     return is_correct
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    33
@@ -189,6 +199,22 @@ class BasePasswordHasher(object):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    34
         """
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    35
         raise NotImplementedError()
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    36
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    37
+    def must_update(self, encoded):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    38
+        return False
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    39
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    40
+    def harden_runtime(self, password, encoded):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    41
+        """
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    42
+        Bridge the runtime gap between the work factor supplied in `encoded`
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    43
+        and the work factor suggested by this hasher.
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    44
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    45
+        Taking PBKDF2 as an example, if `encoded` contains 20000 iterations and
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    46
+        `self.iterations` is 30000, this method should run password through
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    47
+        another 10000 iterations of PBKDF2. Similar approaches should exist
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    48
+        for any hasher that has a work factor. If not, this method should be
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    49
+        defined as a no-op to silence the warning.
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    50
+        """
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    51
+        warnings.warn('subclasses of BasePasswordHasher should provide a harden_runtime() method')
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    52
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    53
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    54
 class PBKDF2PasswordHasher(BasePasswordHasher):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    55
     """
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    56
@@ -227,6 +253,16 @@ class PBKDF2PasswordHasher(BasePasswordH
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    57
             (_('hash'), mask_hash(hash)),
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    58
         ])
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    59
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    60
+    def must_update(self, encoded):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    61
+        algorithm, iterations, salt, hash = encoded.split('$', 3)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    62
+        return int(iterations) != self.iterations
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    63
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    64
+    def harden_runtime(self, password, encoded):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    65
+        algorithm, iterations, salt, hash = encoded.split('$', 3)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    66
+        extra_iterations = self.iterations - int(iterations)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    67
+        if extra_iterations > 0:
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    68
+            self.encode(password, salt, extra_iterations)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    69
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    70
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    71
 class PBKDF2SHA1PasswordHasher(PBKDF2PasswordHasher):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    72
     """
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    73
@@ -278,6 +314,10 @@ class BCryptPasswordHasher(BasePasswordH
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    74
             (_('checksum'), mask_hash(checksum)),
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    75
         ])
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    76
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    77
+    def harden_runtime(self, password, encoded):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    78
+        pass
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    79
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    80
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    81
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    82
 class SHA1PasswordHasher(BasePasswordHasher):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    83
     """
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    84
@@ -334,6 +374,9 @@ class MD5PasswordHasher(BasePasswordHash
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    85
             (_('hash'), mask_hash(hash)),
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    86
         ])
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    87
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    88
+    def harden_runtime(self, password, encoded):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    89
+        pass
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    90
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    91
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    92
 class UnsaltedSHA1PasswordHasher(BasePasswordHasher):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    93
     """
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    94
@@ -366,6 +409,9 @@ class UnsaltedSHA1PasswordHasher(BasePas
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    95
             (_('hash'), mask_hash(hash)),
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    96
         ])
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    97
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    98
+    def harden_runtime(self, password, encoded):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
    99
+        pass
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   100
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   101
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   102
 class UnsaltedMD5PasswordHasher(BasePasswordHasher):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   103
     """
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   104
@@ -399,6 +445,9 @@ class UnsaltedMD5PasswordHasher(BasePass
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   105
             (_('hash'), mask_hash(encoded, show=3)),
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   106
         ])
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   107
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   108
+    def harden_runtime(self, password, encoded):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   109
+        pass
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   110
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   111
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   112
 class CryptPasswordHasher(BasePasswordHasher):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   113
     """
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   114
@@ -434,3 +483,5 @@ class CryptPasswordHasher(BasePasswordHa
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   115
             (_('hash'), mask_hash(data, show=3)),
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   116
         ])
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   117
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   118
+    def harden_runtime(self, password, encoded):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   119
+        pass
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   120
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   121
--- Django-1.4.22/django/contrib/auth/tests/hashers.py.orig    2016-03-09 20:16:47.206793739 -0800
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   122
+++ Django-1.4.22/django/contrib/auth/tests/hashers.py  2016-03-09 20:22:16.148834976 -0800
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   123
@@ -6,6 +6,8 @@ from django.utils import unittest
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   124
 from django.utils.unittest import skipUnless
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   125
 from django.test.utils import override_settings
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   126
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   127
+import mock
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   128
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   129
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   130
 try:
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   131
     import crypt
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   132
@@ -150,3 +152,36 @@ class TestUtilsHashPass(unittest.TestCas
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   133
                 state['upgraded'] = True
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   134
             self.assertFalse(check_password('WRONG', encoded, setter))
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   135
             self.assertFalse(state['upgraded'])
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   136
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   137
+    def test_pbkdf2_harden_runtime(self):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   138
+        hasher = get_hasher('default')
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   139
+        self.assertEqual('pbkdf2_sha256', hasher.algorithm)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   140
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   141
+        with mock.patch.object(hasher, 'iterations', 1):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   142
+            encoded = make_password('letmein')
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   143
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   144
+        with mock.patch.object(hasher, 'iterations', 6), \
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   145
+                mock.patch.object(hasher, 'encode', side_effect=hasher.encode):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   146
+            hasher.harden_runtime('wrong_password', encoded)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   147
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   148
+            # Encode should get called once ...
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   149
+            self.assertEqual(hasher.encode.call_count, 1)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   150
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   151
+            # ... with the original salt and 5 iterations.
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   152
+            algorithm, iterations, salt, hash = encoded.split('$', 3)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   153
+            expected_call = (('wrong_password', salt, 5),)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   154
+            self.assertEqual(hasher.encode.call_args, expected_call)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   155
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   156
+    def test_check_password_calls_harden_runtime(self):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   157
+        hasher = get_hasher('default')
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   158
+        encoded = make_password('letmein')
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   159
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   160
+        with mock.patch.object(hasher, 'harden_runtime'), \
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   161
+                mock.patch.object(hasher, 'must_update', return_value=True):
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   162
+            # Correct password supplied, no hardening needed
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   163
+            check_password('letmein', encoded)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   164
+            self.assertEqual(hasher.harden_runtime.call_count, 0)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   165
+
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   166
+            # Wrong password supplied, hardening needed
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   167
+            check_password('wrong_password', encoded)
c9748fcc32de PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
diff changeset
   168
+            self.assertEqual(hasher.harden_runtime.call_count, 1)