forked from github/dataease
fix: 限制 mysql 非法参数
This commit is contained in:
parent
2a601cfdd6
commit
244b07a3cf
@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
public class Mysql extends DatasourceConfiguration {
|
public class Mysql extends DatasourceConfiguration {
|
||||||
private String driver = "com.mysql.cj.jdbc.Driver";
|
private String driver = "com.mysql.cj.jdbc.Driver";
|
||||||
private String extraParams = "characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true&zeroDateTimeBehavior=convertToNull";
|
private String extraParams = "characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true&zeroDateTimeBehavior=convertToNull";
|
||||||
private List<String> illegalParameters = Arrays.asList("autoDeserialize", "queryInterceptors", "statementInterceptors", "detectCustomCollations");
|
private List<String> illegalParameters = Arrays.asList("autoDeserialize", "queryInterceptors", "statementInterceptors", "detectCustomCollations", "allowloadlocalinfile", "allowUrlInLocalInfile", "allowLoadLocalInfileInPath");
|
||||||
private List<String> showTableSqls = Arrays.asList("show tables");
|
private List<String> showTableSqls = Arrays.asList("show tables");
|
||||||
|
|
||||||
public String getJdbc() {
|
public String getJdbc() {
|
||||||
@ -24,7 +24,7 @@ public class Mysql extends DatasourceConfiguration {
|
|||||||
.replace("DATABASE", getDataBase().trim());
|
.replace("DATABASE", getDataBase().trim());
|
||||||
} else {
|
} else {
|
||||||
for (String illegalParameter : illegalParameters) {
|
for (String illegalParameter : illegalParameters) {
|
||||||
if (getExtraParams().contains(illegalParameter)) {
|
if (getExtraParams().toLowerCase().contains(illegalParameter.toLowerCase())) {
|
||||||
throw new RuntimeException("Illegal parameter: " + illegalParameter);
|
throw new RuntimeException("Illegal parameter: " + illegalParameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user