| | |
| | | package com.gkhy.assess.common.utils; |
| | | |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.gkhy.assess.common.exception.UtilException; |
| | | |
| | | import java.util.List; |
| | |
| | | */ |
| | | 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("参数已超过最大限制,不能进行查询"); |
| | | } |
| | |
| | | */ |
| | | 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注入风险"); |
| | | } |