diff --git a/addons/http_routing/models/ir_http.py b/addons/http_routing/models/ir_http.py index 8ed7527232c..ae72d2d04e2 100644 --- a/addons/http_routing/models/ir_http.py +++ b/addons/http_routing/models/ir_http.py @@ -265,7 +265,7 @@ class IrHttp(models.AbstractModel): session_info.update({ 'translationURL': '/website/translations/', 'cache_hashes': { - 'translations': hashlib.sha1(json.dumps(translation_cache, sort_keys=True).encode()).hexdigest(), + 'translations': hashlib.sha512(json.dumps(translation_cache, sort_keys=True).encode()).hexdigest()[:64], # sha512/256 }, }) return session_info diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 40f351e7f78..b2132850d08 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -567,7 +567,7 @@ class HomeStaticTemplateHelpers(object): :returns: (concatenation_result, checksum) :rtype: (bytes, str) """ - checksum = hashlib.new('sha1') + checksum = hashlib.new('sha512') # sha512/256 if not file_dict: return b'', checksum.hexdigest() @@ -586,7 +586,7 @@ class HomeStaticTemplateHelpers(object): for template in addon.values(): root.append(template) - return etree.tostring(root, encoding='utf-8') if root is not None else b'', checksum.hexdigest() + return etree.tostring(root, encoding='utf-8') if root is not None else b'', checksum.hexdigest()[:64] def _get_qweb_templates(self): """One and only entry point that gets and evaluates static qweb templates diff --git a/addons/web/models/ir_http.py b/addons/web/models/ir_http.py index f5a9f922abf..65ae8073326 100644 --- a/addons/web/models/ir_http.py +++ b/addons/web/models/ir_http.py @@ -62,9 +62,9 @@ class Http(models.AbstractModel): "show_effect": True, "display_switch_company_menu": user.has_group('base.group_multi_company') and len(user.company_ids) > 1, "cache_hashes": { - "load_menus": hashlib.sha1(menu_json_utf8).hexdigest(), + "load_menus": hashlib.sha512(menu_json_utf8).hexdigest()[:64], # sha512/256 "qweb": qweb_checksum, - "translations": hashlib.sha1(translations_json_utf8).hexdigest(), + "translations": hashlib.sha512(translations_json_utf8).hexdigest()[:64], # sha512/256 }, } diff --git a/addons/web/models/ir_qweb.py b/addons/web/models/ir_qweb.py index 1083916ebf5..6776dbbff14 100644 --- a/addons/web/models/ir_qweb.py +++ b/addons/web/models/ir_qweb.py @@ -43,7 +43,7 @@ class Image(models.AbstractModel): if max_width or max_height: max_size = '%sx%s' % (max_width, max_height) - sha = hashlib.sha1(str(getattr(record, '__last_update')).encode('utf-8')).hexdigest()[0:7] + sha = hashlib.sha512(str(getattr(record, '__last_update')).encode('utf-8')).hexdigest()[:7] max_size = '' if max_size is None else '/%s' % max_size if options.get('filename-field') and getattr(record, options['filename-field'], None): diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 3902f5dae8a..56bdf09e972 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -787,7 +787,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(str(getattr(sudo_record, '__last_update')).encode('utf-8')).hexdigest()[0:7] + sha = hashlib.sha512(str(getattr(sudo_record, '__last_update')).encode('utf-8')).hexdigest()[: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/odoo/addons/base/models/assetsbundle.py b/odoo/addons/base/models/assetsbundle.py index d1554594aa3..e46a779dd28 100644 --- a/odoo/addons/base/models/assetsbundle.py +++ b/odoo/addons/base/models/assetsbundle.py @@ -186,10 +186,10 @@ class AssetsBundle(object): def checksum(self): """ Not really a full checksum. - We compute a SHA1 on the rendered bundle + max linked files last_modified date + We compute a SHA512/256 on the rendered bundle + max linked files last_modified date """ check = u"%s%s" % (json.dumps(self.files, sort_keys=True), self.last_modified) - return hashlib.sha1(check.encode('utf-8')).hexdigest() + return hashlib.sha512(check.encode('utf-8')).hexdigest()[:64] def _get_asset_template_url(self): return "/web/content/{id}-{unique}/{extra}{name}{sep}{type}" diff --git a/odoo/addons/base/models/ir_http.py b/odoo/addons/base/models/ir_http.py index 64ab86aea9b..5e142222eda 100644 --- a/odoo/addons/base/models/ir_http.py +++ b/odoo/addons/base/models/ir_http.py @@ -152,7 +152,7 @@ class IrHttp(models.AbstractModel): wdate = attach[0]['__last_update'] datas = attach[0]['datas'] or b'' name = attach[0]['name'] - checksum = attach[0]['checksum'] or hashlib.sha1(datas).hexdigest() + checksum = attach[0]['checksum'] or hashlib.sha512(datas).hexdigest()[:64] # sha512/256 if (not datas and name != request.httprequest.path and name.startswith(('http://', 'https://', '/'))):