From 79fc35b1aa90d0d1be1903ccedac4afb3c803839 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 19 Sep 2019 15:27:24 -0400 Subject: [PATCH 1/2] In python 3 unicode strings don't auto coerce to bytes. We have to explictily pass byte objects to hashing functions because that's what the want to hash. --- edx_proctoring/__init__.py | 2 +- edx_proctoring/utils.py | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/edx_proctoring/__init__.py b/edx_proctoring/__init__.py index ff02a2c3881..8c06ac15720 100644 --- a/edx_proctoring/__init__.py +++ b/edx_proctoring/__init__.py @@ -5,6 +5,6 @@ from __future__ import absolute_import # Be sure to update the version number in edx_proctoring/package.json -__version__ = '2.0.8' +__version__ = '2.0.9' default_app_config = 'edx_proctoring.apps.EdxProctoringConfig' # pylint: disable=invalid-name diff --git a/edx_proctoring/utils.py b/edx_proctoring/utils.py index 342c39ded35..27a39c27a8d 100644 --- a/edx_proctoring/utils.py +++ b/edx_proctoring/utils.py @@ -229,8 +229,8 @@ def obscured_user_id(user_id, *extra): Any extra information can be added to the hash """ obs_hash = hmac.new(settings.SECRET_KEY.encode('ascii'), digestmod=hashlib.sha1) - obs_hash.update(six.text_type(user_id)) - obs_hash.update(u''.join(six.text_type(ext) for ext in extra)) + obs_hash.update(user_id.encode('utf-8')) + obs_hash.update(b''.join(ext.encode('utf-8') for ext in extra)) return obs_hash.hexdigest() diff --git a/package.json b/package.json index c12149a6999..8ca41ba5628 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@edx/edx-proctoring", "//": "Be sure to update the version number in edx_proctoring/__init__.py", "//": "Note that the version format is slightly different than that of the Python version when using prereleases.", - "version": "2.0.8", + "version": "2.0.9", "main": "edx_proctoring/static/index.js", "repository": { "type": "git", From 3372c821301e32d14c8700a3aeaddd189781ddce Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 19 Sep 2019 15:51:05 -0400 Subject: [PATCH 2/2] Need to make sure we encode strings. --- edx_proctoring/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/edx_proctoring/utils.py b/edx_proctoring/utils.py index 27a39c27a8d..4e12bee39e2 100644 --- a/edx_proctoring/utils.py +++ b/edx_proctoring/utils.py @@ -229,8 +229,8 @@ def obscured_user_id(user_id, *extra): Any extra information can be added to the hash """ obs_hash = hmac.new(settings.SECRET_KEY.encode('ascii'), digestmod=hashlib.sha1) - obs_hash.update(user_id.encode('utf-8')) - obs_hash.update(b''.join(ext.encode('utf-8') for ext in extra)) + obs_hash.update(six.text_type(user_id).encode('utf-8')) + obs_hash.update(b''.join(six.text_type(ext).encode('utf-8') for ext in extra)) return obs_hash.hexdigest()