diff options
| author | Xavier Morel <xmo@odoo.com> | 2017-05-15 17:27:24 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2017-08-20 23:25:54 +0200 |
| commit | 481a00dc4b82bc1b2cbbd6079a147fe230ac57bd (patch) | |
| tree | 975b178f4e4a3733b904bd511d905160014ec009 /addons | |
| parent | 9d83784f1df18306b6166fd92a0573f39bf6262d (diff) | |
[FIX] P3: hash/hmac payload must be bytes
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/hw_escpos/escpos/escpos.py | 2 | ||||
| -rw-r--r-- | addons/mail/models/mail_thread.py | 2 | ||||
| -rw-r--r-- | addons/mass_mailing/models/mass_mailing.py | 2 | ||||
| -rw-r--r-- | addons/payment/models/payment_acquirer.py | 2 | ||||
| -rw-r--r-- | addons/payment_adyen/models/payment.py | 2 | ||||
| -rw-r--r-- | addons/payment_authorize/models/payment.py | 2 | ||||
| -rw-r--r-- | addons/payment_authorize/tests/test_authorize.py | 2 | ||||
| -rw-r--r-- | addons/payment_payumoney/models/payment.py | 2 | ||||
| -rw-r--r-- | addons/payment_sips/models/payment.py | 2 | ||||
| -rw-r--r-- | addons/web_editor/models/ir_qweb.py | 2 | ||||
| -rw-r--r-- | addons/website/models/website.py | 2 | ||||
| -rw-r--r-- | addons/website_forum/models/res_users.py | 5 | ||||
| -rw-r--r-- | addons/website_mail/controllers/main.py | 1 | ||||
| -rw-r--r-- | addons/website_mail_channel/models/mail_channel.py | 2 |
14 files changed, 15 insertions, 15 deletions
diff --git a/addons/hw_escpos/escpos/escpos.py b/addons/hw_escpos/escpos/escpos.py index f076778ca9c..7159ac3b31e 100644 --- a/addons/hw_escpos/escpos/escpos.py +++ b/addons/hw_escpos/escpos/escpos.py @@ -433,7 +433,7 @@ class Escpos: print('print_b64_img') - id = md5(img).digest() + id = md5(img.encode('utf-8')).digest() if id not in self.img_cache: print('not in cache') diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index bc7b1d1072d..8dfe1ef452c 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -570,7 +570,7 @@ class MailThread(models.AbstractModel): def _generate_notification_token(self, base_link, params): secret = self.env['ir.config_parameter'].sudo().get_param('database.secret') token = '%s?%s' % (base_link, ' '.join('%s=%s' % (key, params[key]) for key in sorted(params))) - hm = hmac.new(str(secret), token, hashlib.sha1).hexdigest() + hm = hmac.new(secret.encode('utf-8'), token.encode('utf-8'), hashlib.sha1).hexdigest() return hm @api.multi diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py index 44993bdc907..a10e6143c89 100644 --- a/addons/mass_mailing/models/mass_mailing.py +++ b/addons/mass_mailing/models/mass_mailing.py @@ -430,7 +430,7 @@ class MassMailing(models.Model): secret = self.env["ir.config_parameter"].sudo().get_param( "database.secret") token = (self.env.cr.dbname, self.id, int(res_id), tools.ustr(email)) - return hmac.new(str(secret), repr(token), hashlib.sha512).hexdigest() + return hmac.new(secret.encode('utf-8'), repr(token).encode('utf-8'), hashlib.sha512).hexdigest() def _compute_next_departure(self): cron_next_call = self.env.ref('mass_mailing.ir_cron_mass_mailing_queue').sudo().nextcall diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index 623676c7a9c..909536ac95c 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -583,7 +583,7 @@ class PaymentTransaction(models.Model): token = '%s%s%s' % (self.callback_model_id.model, self.callback_res_id, self.sudo().callback_method) - return hmac.new(str(secret), token, hashlib.sha256).hexdigest() + return hmac.new(secret.encode('utf-8'), token.encode('utf-8'), hashlib.sha256).hexdigest() # -------------------------------------------------- # FORM RELATED METHODS diff --git a/addons/payment_adyen/models/payment.py b/addons/payment_adyen/models/payment.py index 87e51e619cb..787160fd1ea 100644 --- a/addons/payment_adyen/models/payment.py +++ b/addons/payment_adyen/models/payment.py @@ -54,7 +54,7 @@ class AcquirerAdyen(models.Model): escapeVal(v) for v in chain(pycompat.keys(parms), pycompat.values(parms)) ) - hm = hmac.new(hmac_key, signing_string, hashlib.sha256) + hm = hmac.new(hmac_key, signing_string.encode('utf-8'), hashlib.sha256) return base64.b64encode(hm.digest()) assert inout in ('in', 'out') diff --git a/addons/payment_authorize/models/payment.py b/addons/payment_authorize/models/payment.py index bfc5bfd569a..caa15732e15 100644 --- a/addons/payment_authorize/models/payment.py +++ b/addons/payment_authorize/models/payment.py @@ -54,7 +54,7 @@ class PaymentAcquirerAuthorize(models.Model): values['x_fp_timestamp'], values['x_amount'], values['x_currency_code']]) - return hmac.new(str(values['x_trans_key']), data, hashlib.md5).hexdigest() + return hmac.new(values['x_trans_key'].encode('utf-8'), data.encode('utf-8'), hashlib.md5).hexdigest() @api.multi def authorize_form_generate_values(self, values): diff --git a/addons/payment_authorize/tests/test_authorize.py b/addons/payment_authorize/tests/test_authorize.py index 668e17d0562..6d3f4244583 100644 --- a/addons/payment_authorize/tests/test_authorize.py +++ b/addons/payment_authorize/tests/test_authorize.py @@ -39,7 +39,7 @@ class AuthorizeForm(AuthorizeCommon): values['x_fp_timestamp'], values['x_amount'], ]) + '^' - return hmac.new(str(values['x_trans_key']), data, hashlib.md5).hexdigest() + return hmac.new(values['x_trans_key'].encode('utf-8'), data.encode('utf-8'), hashlib.md5).hexdigest() def test_10_Authorize_form_render(self): self.assertEqual(self.authorize.environment, 'test', 'test without test environment') diff --git a/addons/payment_payumoney/models/payment.py b/addons/payment_payumoney/models/payment.py index 243ef5cef53..cbda9e64527 100644 --- a/addons/payment_payumoney/models/payment.py +++ b/addons/payment_payumoney/models/payment.py @@ -49,7 +49,7 @@ class PaymentAcquirerPayumoney(models.Model): sign = ''.join('%s|' % (values.get(k) or '') for k in keys) sign = self.payumoney_merchant_salt + sign + self.payumoney_merchant_key - shasign = hashlib.sha512(sign).hexdigest() + shasign = hashlib.sha512(sign.encode('utf-8')).hexdigest() return shasign @api.multi diff --git a/addons/payment_sips/models/payment.py b/addons/payment_sips/models/payment.py index f01c59d1880..a6c9b390eae 100644 --- a/addons/payment_sips/models/payment.py +++ b/addons/payment_sips/models/payment.py @@ -66,7 +66,7 @@ class AcquirerSips(models.Model): if self.environment == 'prod': key = getattr(self, 'sips_secret') - shasign = sha256(data + key) + shasign = sha256((data + key).encode('utf-8')) return shasign.hexdigest() @api.multi diff --git a/addons/web_editor/models/ir_qweb.py b/addons/web_editor/models/ir_qweb.py index 4b1cd512e06..f4a25a8b990 100644 --- a/addons/web_editor/models/ir_qweb.py +++ b/addons/web_editor/models/ir_qweb.py @@ -315,7 +315,7 @@ class Image(models.AbstractModel): if max_width or max_height: max_size = '%sx%s' % (max_width, max_height) - sha = hashlib.sha1(getattr(record, '__last_update')).hexdigest()[0:7] + sha = hashlib.sha1(getattr(record, '__last_update').encode('utf-8')).hexdigest()[0:7] max_size = '' if max_size is None else '/%s' % max_size src = '/web/image/%s/%s/%s%s?unique=%s' % (record._name, record.id, field_name, max_size, sha) diff --git a/addons/website/models/website.py b/addons/website/models/website.py index c46e3c2a327..fd6ee0f2841 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -584,7 +584,7 @@ class Website(models.Model): def image_url(self, record, field, size=None): """ Returns a local url that points to the image field of a given browse record. """ sudo_record = record.sudo() - sha = hashlib.sha1(getattr(sudo_record, '__last_update')).hexdigest()[0:7] + sha = hashlib.sha1(getattr(sudo_record, '__last_update').encode('utf-8')).hexdigest()[0:7] size = '' if size is None else '/%s' % size return '/web/image/%s/%s/%s%s?unique=%s' % (record._name, record.id, field, size, sha) diff --git a/addons/website_forum/models/res_users.py b/addons/website_forum/models/res_users.py index 9d22ee3c9d8..054e3a4d56a 100644 --- a/addons/website_forum/models/res_users.py +++ b/addons/website_forum/models/res_users.py @@ -66,11 +66,12 @@ class Users(models.Model): and is a hash based on a (secret) uuid generated by the forum module, the user_id, the email and currently the day (to be updated if necessary). """ forum_uuid = self.env['ir.config_parameter'].sudo().get_param('website_forum.uuid') - return hashlib.sha256('%s-%s-%s-%s' % ( + return hashlib.sha256((u'%s-%s-%s-%s' % ( datetime.now().replace(hour=0, minute=0, second=0, microsecond=0), forum_uuid, user_id, - email)).hexdigest() + email + )).encode('utf-8')).hexdigest() @api.one def send_forum_validation_email(self, forum_id=None): diff --git a/addons/website_mail/controllers/main.py b/addons/website_mail/controllers/main.py index c10525fd5e0..ab42fb5c3b5 100644 --- a/addons/website_mail/controllers/main.py +++ b/addons/website_mail/controllers/main.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. - from werkzeug.exceptions import NotFound, Forbidden from odoo import http diff --git a/addons/website_mail_channel/models/mail_channel.py b/addons/website_mail_channel/models/mail_channel.py index 519dfe7afc6..79c6cc27287 100644 --- a/addons/website_mail_channel/models/mail_channel.py +++ b/addons/website_mail_channel/models/mail_channel.py @@ -68,4 +68,4 @@ class MailGroup(models.Model): str(self.id), str(partner_id), action]) - return hmac.new(secret.encode('utf-8'), data).hexdigest() + return hmac.new(secret.encode('utf-8'), data.encode('utf-8')).hexdigest() |
