From a1c78df6d34b418a6771cf86d58a04a2ff566757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20M=C3=BCller?= Date: Thu, 6 Aug 2026 02:17:43 +0300 Subject: [PATCH] Potential fix for code scanning alert no. 12: Clear text storage of sensitive information MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Albert Müller --- others/translate/translate.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/others/translate/translate.js b/others/translate/translate.js index 4601f80..18a610e 100644 --- a/others/translate/translate.js +++ b/others/translate/translate.js @@ -282,16 +282,19 @@ const TranslateApp = { TranslateAPI.setService(currentService); } - // 保存到本地存储(移除敏感字段,避免明文持久化) - const safeApiConfig = JSON.parse(JSON.stringify(apiConfig)); - if (safeApiConfig.baidu) { - delete safeApiConfig.baidu.secretKey; - } - if (safeApiConfig.youdao) { - delete safeApiConfig.youdao.secretKey; + // 保存到本地存储(仅持久化非敏感字段,避免明文持久化密钥) + const safeApiConfig = { + service: currentService + }; + if (baiduAppId) { + safeApiConfig.baidu = { + appId: baiduAppId + }; } - if (safeApiConfig.google) { - delete safeApiConfig.google.apiKey; + if (youdaoAppId) { + safeApiConfig.youdao = { + appId: youdaoAppId + }; } localStorage.setItem('translateApiConfig', JSON.stringify(safeApiConfig));