This commit is contained in:
shanhexi
2023-08-13 17:34:43 +08:00
6 changed files with 27 additions and 38 deletions

View File

@@ -12,6 +12,7 @@
"blockmap",
"cascader",
"chmod",
"CLOB",
"datasource",
"DBAI",
"DBHUB",

View File

@@ -2,7 +2,7 @@
## ⭐ New Features
- Supports viewing views, functions, triggers, and procedures
- 🔥Supports viewing views, functions, triggers, and procedures
- Support selected sql formatting
- Added new dark themes
@@ -11,10 +11,11 @@
- Fixed sql formatting failure issue
- Fixed an issue where locally stored theme colors and background colors are incompatible with the new version, causing page crashes
- Logs desensitize sensitive data
- Fix the issue of 'CLOB' not displaying specific content [Issue #440](https://github.com/chat2db/Chat2DB/issues/440)
## ⭐ 新特性
- 支持查看视图、函数、触发器、过程
- 🔥支持查看视图、函数、触发器、存储过程
- 支持选中sql格式化
- 增加新的暗色主题
@@ -23,7 +24,7 @@
- 修复sql格式化会失败问题
- 修复本地存储的主题色、背景色与新版本不兼容时会导致页面崩溃问题
- 日志对敏感数据进行脱敏
- 修复 `CLOB` 不展示具体内容的问题 [Issue #440](https://github.com/chat2db/Chat2DB/issues/440)
# 2.0.11

View File

@@ -54,10 +54,10 @@ public class EasyLogSink implements Sink {
webLog.setStartTime(LocalDateTime.ofInstant(correlation.getStart(), ZoneId.systemDefault()));
webLog.setEndTime(LocalDateTime.ofInstant(correlation.getEnd(), ZoneId.systemDefault()));
try {
webLog.setRequest(LogUtils.cutLog(new String(request.getBody(), StandardCharsets.UTF_8)));
webLog.setRequest(LogUtils.maskString(LogUtils.cutLog(new String(request.getBody(), StandardCharsets.UTF_8))));
if (ContentTypeUtils.isContentTypeJSON(response.getContentType()) || ContentTypeUtils.isContentTypeHTML(
response.getContentType())) {
webLog.setResponse(LogUtils.cutLog(new String(response.getBody(), StandardCharsets.UTF_8)));
webLog.setResponse(LogUtils.maskString(LogUtils.cutLog(new String(response.getBody(), StandardCharsets.UTF_8))));
} else {
webLog.setResponse(response.getContentType() + ":[" + response.getBody().length + "]");
}

View File

@@ -1,32 +0,0 @@
package ai.chat2db.server.start.log;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
@Slf4j
@Component
public class MyInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//// 处理逻辑
//MyResult result = new MyResult();
//result.setCode(200);
//result.setMessage("处理成功");
//request.setAttribute("myResult", result);
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//// 取出处理结果并封装成实体对象
//MyResult result = (MyResult) request.getAttribute("myResult");
//modelAndView.setView(new MappingJackson2JsonView());
//modelAndView.addObject(result);
log.info("xx");
}
}

View File

@@ -5,6 +5,7 @@ import java.util.regex.Pattern;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.net.NetUtil;
import org.apache.commons.lang3.StringUtils;
import org.zalando.logbook.HttpHeaders;
import org.zalando.logbook.HttpRequest;
@@ -36,6 +37,24 @@ public class LogUtils {
*/
private static final Pattern LINE_FEED_PATTERN = Pattern.compile("\r|\n");
/**
* mask string
*
* @param input
* @return
*/
public static String maskString(String input) {
if (StringUtils.isBlank(input)) {
return input;
}
StringBuilder maskedString = new StringBuilder(input);
for (int i = 0; i < input.length(); i += 4) {
maskedString.setCharAt(i, '*');
}
return maskedString.toString();
}
/**
* 去除换行符
*

View File

@@ -151,7 +151,7 @@ public class JdbcUtils {
return "(BLOB " + blob.length() + ")";
}
if (obj instanceof Clob clob) {
return "(CLOB " + clob.length() + ")";
return clob.getSubString(1, Math.toIntExact(clob.length()));
}
if (obj instanceof Timestamp timestamp) {
return Objects.toString(timestamp);