From c0585c03293f768d72590627aa7fc5a8a68e55fb Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Tue, 14 Feb 2023 14:13:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97=E5=AF=B9=E9=9B=86=E6=88=90?= =?UTF-8?q?=E7=9A=84=E5=B9=B3=E5=8F=B0=E8=B4=A6=E6=88=B7=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=BA=E6=98=8E=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1022910 --user=李玉号 【系统设置】github#21736,操作日志对集成的平台账户密码显示为明文 https://www.tapd.cn/55049933/s/1335012 Closes #21736 --- .../log/utils/ReflexObjectUtil.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java index 4bb8d428f7..848f469103 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java @@ -1,8 +1,10 @@ package io.metersphere.log.utils; +import com.fasterxml.jackson.core.type.TypeReference; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; +import io.metersphere.commons.constants.OperLogModule; import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.JSON; import io.metersphere.commons.utils.LogUtil; @@ -211,6 +213,29 @@ public class ReflexObjectUtil { String oldValue = Objects.toString(column.getOriginalValue(), ""); column.setDiffValue(ApiTestEnvironmentDiffUtil.diff(newValue, oldValue)); } + } + // 不记录服务集成配置信息中密码字段 + else if (StringUtils.equals(module, OperLogModule.WORKSPACE_SERVICE_INTEGRATION)) { + if (StringUtils.equals(column.getColumnName(), "configuration")) { + if (column.getNewValue() != null && column.getOriginalValue() == null) { + HashMap newConf = JSON.parseObject((String) column.getNewValue(), new TypeReference<>() {}); + newConf.put("password", "******"); + column.setNewValue(JSON.toJSONString(newConf)); + } else if (column.getOriginalValue() != null && column.getNewValue() != null) { + HashMap newConf = JSON.parseObject((String) column.getNewValue(), new TypeReference<>() {}); + HashMap oldConf = JSON.parseObject((String) column.getOriginalValue(), new TypeReference<>() {}); + if (StringUtils.equals((String)newConf.get("password"), (String)oldConf.get("password"))) { + // 密码未修改,保持一致 + oldConf.put("password", "******"); + newConf.put("password", "******"); + } else { + oldConf.put("password", "******"); + newConf.put("password", "*********"); + } + column.setOriginalValue(JSON.toJSONString(oldConf)); + column.setNewValue(JSON.toJSONString(newConf)); + } + } } else { String newValue = Objects.toString(column.getNewValue(), ""); if (StringUtils.isNotEmpty(newValue)) {