修复漏洞(对报错信息进行自定义,避免泄露系统敏感信息)

This commit is contained in:
sh
2026-04-28 20:01:03 +08:00
parent 7d8f941c85
commit 3c273ea5b7

View File

@@ -1,6 +1,8 @@
package com.ruoyi.framework.web.exception;
import javax.servlet.http.HttpServletRequest;
import com.highgo.jdbc.util.PSQLException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDeniedException;
@@ -98,7 +100,14 @@ public class GlobalExceptionHandler
{
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生未知异常.", requestURI, e);
return AjaxResult.error(e.getMessage());
String msg = e.getMessage();
if (msg != null && msg.contains("对于字符类型来说这个值太长了")) {
return AjaxResult.error("输入内容过长,请检查后重试");
}
return AjaxResult.error("服务器异常,请稍后重试");
//return AjaxResult.error(e.getMessage());
}
/**
@@ -142,4 +151,12 @@ public class GlobalExceptionHandler
{
return AjaxResult.error("演示模式,不允许操作");
}
/**
* 拦截瀚高数据库 字符过长异常
*/
@ExceptionHandler(PSQLException.class)
public AjaxResult handleHighGoException(PSQLException e) {
return AjaxResult.error("输入内容过长,请检查后重试");
}
}