kongzy
2023-12-08 ca5445257b1fdeceddf3fcc2dea18c442023aeb7
assess-common/src/main/java/com/gkhy/assess/common/utils/SqlUtil.java
@@ -1,7 +1,5 @@
package com.gkhy.assess.common.utils;
import cn.hutool.core.util.StrUtil;
import com.gkhy.assess.common.exception.UtilException;
import java.util.List;
@@ -33,11 +31,11 @@
     */
    public static String escapeOrderBySql(String value)
    {
        if (StrUtil.isNotEmpty(value) && !isValidOrderBySql(value))
        if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value))
        {
            throw new UtilException("参数不符合规范,不能进行查询");
        }
        if (StrUtil.length(value) > ORDER_BY_MAX_LENGTH)
        if (StringUtils.length(value) > ORDER_BY_MAX_LENGTH)
        {
            throw new UtilException("参数已超过最大限制,不能进行查询");
        }
@@ -57,14 +55,14 @@
     */
    public static void filterKeyword(String value)
    {
        if (StrUtil.isEmpty(value))
        if (StringUtils.isEmpty(value))
        {
            return;
        }
        List<String> sqlKeywords = StrUtil.split(SQL_REGEX, "\\|");
        List<String> sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
        for (String sqlKeyword : sqlKeywords)
        {
            if (StrUtil.indexOfIgnoreCase(value, sqlKeyword) > -1)
            if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1)
            {
                throw new UtilException("参数存在SQL注入风险");
            }