mirror of https://github.com/jeecgboot/jeecg-boot
【issues/4393】解决使用参数tableName=sys_user t&复测,漏洞仍然存在
parent
0bc7e0967d
commit
751b81c7bf
|
@ -1,6 +1,7 @@
|
||||||
package org.jeecg.common.util.security;
|
package org.jeecg.common.util.security;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -59,7 +60,7 @@ public abstract class AbstractQueryBlackListHandler {
|
||||||
if(list==null){
|
if(list==null){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
log.info("--获取sql信息--", list.toString());
|
log.info(" 获取sql信息 :{} ", list.toString());
|
||||||
boolean flag = checkTableAndFieldsName(list);
|
boolean flag = checkTableAndFieldsName(list);
|
||||||
if(flag == false){
|
if(flag == false){
|
||||||
return false;
|
return false;
|
||||||
|
@ -189,21 +190,21 @@ public abstract class AbstractQueryBlackListHandler {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean existSameField(String fieldString) {
|
public boolean existSameField(String fieldString) {
|
||||||
String[] arr = fieldString.split(",");
|
String[] controlFields = fieldString.split(",");
|
||||||
for (String exp : fields) {
|
for (String sqlField : fields) {
|
||||||
for (String config : arr) {
|
for (String controlField : controlFields) {
|
||||||
if (exp.equals(config)) {
|
if (sqlField.equals(controlField)) {
|
||||||
// 非常明确的列直接比较
|
// 非常明确的列直接比较
|
||||||
log.warn("sql黑名单校验,表【"+name+"】中字段【"+config+"】禁止查询");
|
log.warn("sql黑名单校验,表【"+name+"】中字段【"+controlField+"】禁止查询");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// 使用表达式的列 只能判读字符串包含了
|
// 使用表达式的列 只能判读字符串包含了
|
||||||
String aliasColumn = config;
|
String aliasColumn = controlField;
|
||||||
if (alias != null && alias.length() > 0) {
|
if (StringUtils.isNotBlank(alias)) {
|
||||||
aliasColumn = alias + "." + config;
|
aliasColumn = alias + "." + controlField;
|
||||||
}
|
}
|
||||||
if (exp.indexOf(aliasColumn) > 0) {
|
if (sqlField.indexOf(aliasColumn) != -1) {
|
||||||
log.warn("sql黑名单校验,表【"+name+"】中字段【"+config+"】禁止查询");
|
log.warn("sql黑名单校验,表【"+name+"】中字段【"+controlField+"】禁止查询");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,9 @@ public class DictQueryBlackListHandler extends AbstractQueryBlackListHandler {
|
||||||
if (tableName.contains(" ")) {
|
if (tableName.contains(" ")) {
|
||||||
tableName = tableName.substring(0, tableName.indexOf(" "));
|
tableName = tableName.substring(0, tableName.indexOf(" "));
|
||||||
}
|
}
|
||||||
|
if (tableName.contains(".")) {
|
||||||
|
tableName = tableName.substring(tableName.indexOf(".")+1, tableName.length());
|
||||||
|
}
|
||||||
//【issues/4393】 sys_user , (sys_user), sys_user%20, %60sys_user%60
|
//【issues/4393】 sys_user , (sys_user), sys_user%20, %60sys_user%60
|
||||||
String reg = "\\s+|\\(|\\)|`";
|
String reg = "\\s+|\\(|\\)|`";
|
||||||
return tableName.replaceAll(reg, "");
|
return tableName.replaceAll(reg, "");
|
||||||
|
|
Loading…
Reference in New Issue