From e4033fd662d0f002012b2cacd5db9f97be4f034c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=8B=BE=E9=A3=8E?= <3431391539@qq.com> Date: Thu, 13 Nov 2025 21:04:02 +0800 Subject: [PATCH] Potential fix for code scanning alert no. 26: Use of a broken or weak cryptographic hashing algorithm on sensitive data Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- src/common/database/utils/decorators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/database/utils/decorators.py b/src/common/database/utils/decorators.py index f5cc2f04a..319debcb1 100644 --- a/src/common/database/utils/decorators.py +++ b/src/common/database/utils/decorators.py @@ -176,13 +176,13 @@ def cached( if use_args and args: # 将位置参数转换为字符串 args_str = ",".join(str(arg) for arg in args) - args_hash = hashlib.md5(args_str.encode()).hexdigest()[:8] + args_hash = hashlib.sha256(args_str.encode()).hexdigest()[:8] cache_key_parts.append(f"args:{args_hash}") if use_kwargs and kwargs: # 将关键字参数转换为字符串(排序以保证一致性) kwargs_str = ",".join(f"{k}={v}" for k, v in sorted(kwargs.items())) - kwargs_hash = hashlib.md5(kwargs_str.encode()).hexdigest()[:8] + kwargs_hash = hashlib.sha256(kwargs_str.encode()).hexdigest()[:8] cache_key_parts.append(f"kwargs:{kwargs_hash}") cache_key = ":".join(cache_key_parts)