From ecfba94e47e7d4167b36d37bb3fbe4724b86bb94 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期四, 19 一月 2023 12:05:59 +0800
Subject: [PATCH] 升级fastjson到最新版2.0.23
---
src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java b/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java
index ceff841..40a800d 100644
--- a/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java
+++ b/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java
@@ -11,6 +11,11 @@
public class SqlUtil
{
/**
+ * 瀹氫箟甯哥敤鐨� sql鍏抽敭瀛�
+ */
+ public static String SQL_REGEX = "and |extractvalue|updatexml|exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |or |+|user()";
+
+ /**
* 浠呮敮鎸佸瓧姣嶃�佹暟瀛椼�佷笅鍒掔嚎銆佺┖鏍笺�侀�楀彿銆佸皬鏁扮偣锛堟敮鎸佸涓瓧娈垫帓搴忥級
*/
public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
@@ -34,4 +39,23 @@
{
return value.matches(SQL_PATTERN);
}
+
+ /**
+ * SQL鍏抽敭瀛楁鏌�
+ */
+ public static void filterKeyword(String value)
+ {
+ if (StringUtils.isEmpty(value))
+ {
+ return;
+ }
+ String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
+ for (String sqlKeyword : sqlKeywords)
+ {
+ if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1)
+ {
+ throw new UtilException("鍙傛暟瀛樺湪SQL娉ㄥ叆椋庨櫓");
+ }
+ }
+ }
}
--
Gitblit v1.9.3