fix: 【漏洞】Dataease H2 JDBC RCE Bypass's Bypass

This commit is contained in:
taojinlong
2025-08-05 16:49:01 +08:00
committed by taojinlong
parent 8d04e92d44
commit 1644d81dff
9 changed files with 35 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
package io.dataease.datasource.type;
import io.dataease.exception.DEException;
import io.dataease.extensions.datasource.vo.DatasourceConfiguration;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
@@ -12,15 +13,18 @@ public class CK extends DatasourceConfiguration {
private String extraParams = "";
public String getJdbc() {
if(StringUtils.isNoneEmpty(getUrlType()) && !getUrlType().equalsIgnoreCase("hostName")){
if (StringUtils.isNoneEmpty(getUrlType()) && !getUrlType().equalsIgnoreCase("hostName")) {
if (!getJdbcUrl().startsWith("jdbc:clickhouse")) {
DEException.throwException("Illegal jdbcUrl: " + getJdbcUrl());
}
return getJdbcUrl();
}
if(StringUtils.isEmpty(extraParams.trim())){
if (StringUtils.isEmpty(extraParams.trim())) {
return "jdbc:clickhouse://HOSTNAME:PORT/DATABASE"
.replace("HOSTNAME", getLHost().trim())
.replace("PORT", getLPort().toString().trim())
.replace("DATABASE", getDataBase().trim());
}else {
} else {
return "jdbc:clickhouse://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS"
.replace("HOSTNAME", getLHost().trim())
.replace("PORT", getLPort().toString().trim())

View File

@@ -23,6 +23,9 @@ public class Db2 extends DatasourceConfiguration {
DEException.throwException("Illegal parameter: " + illegalParameter);
}
}
if (!getJdbcUrl().startsWith("jdbc:db2")) {
DEException.throwException("Illegal jdbcUrl: " + getJdbcUrl());
}
return getJdbcUrl();
}
if (StringUtils.isEmpty(extraParams.trim())) {

View File

@@ -1,5 +1,6 @@
package io.dataease.datasource.type;
import io.dataease.exception.DEException;
import io.dataease.extensions.datasource.vo.DatasourceConfiguration;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
@@ -18,6 +19,9 @@ public class Impala extends DatasourceConfiguration {
public String getJdbc() {
if(StringUtils.isNoneEmpty(getUrlType()) && !getUrlType().equalsIgnoreCase("hostName")){
if (!getJdbcUrl().startsWith("jdbc:impala")) {
DEException.throwException("Illegal jdbcUrl: " + getJdbcUrl());
}
return getJdbcUrl();
}
if(StringUtils.isEmpty(extraParams.trim())){

View File

@@ -1,5 +1,6 @@
package io.dataease.datasource.type;
import io.dataease.exception.DEException;
import io.dataease.extensions.datasource.vo.DatasourceConfiguration;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
@@ -18,6 +19,9 @@ public class Mongo extends DatasourceConfiguration {
public String getJdbc() {
if(StringUtils.isNoneEmpty(getUrlType()) && !getUrlType().equalsIgnoreCase("hostName")){
if (!getJdbcUrl().startsWith("jdbc:mysql")) {
DEException.throwException("Illegal jdbcUrl: " + getJdbcUrl());
}
return getJdbcUrl();
}
if (StringUtils.isEmpty(extraParams.trim())) {

View File

@@ -25,6 +25,9 @@ public class Mysql extends DatasourceConfiguration {
DEException.throwException("Illegal parameter: " + illegalParameter);
}
}
if (!getJdbcUrl().startsWith("jdbc:mysql")) {
DEException.throwException("Illegal jdbcUrl: " + getJdbcUrl());
}
return getJdbcUrl();
}
String jdbcUrl = "";

View File

@@ -1,5 +1,6 @@
package io.dataease.datasource.type;
import io.dataease.exception.DEException;
import io.dataease.extensions.datasource.vo.DatasourceConfiguration;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
@@ -13,6 +14,9 @@ public class Oracle extends DatasourceConfiguration {
public String getJdbc() {
if(StringUtils.isNoneEmpty(getUrlType()) && !getUrlType().equalsIgnoreCase("hostName")){
if (!getJdbcUrl().startsWith("jdbc:oracle")) {
DEException.throwException("Illegal jdbcUrl: " + getJdbcUrl());
}
return getJdbcUrl();
}
if (StringUtils.isNotEmpty(getConnectionType()) && getConnectionType().equalsIgnoreCase("serviceName")) {

View File

@@ -24,6 +24,9 @@ public class Pg extends DatasourceConfiguration {
DEException.throwException("Illegal parameter: " + illegalParameter);
}
}
if (!getJdbcUrl().startsWith("jdbc:postgresql")) {
DEException.throwException("Illegal jdbcUrl: " + getJdbcUrl());
}
return getJdbcUrl();
}
String jdbcUrl = "";

View File

@@ -24,6 +24,9 @@ public class Redshift extends DatasourceConfiguration {
DEException.throwException("Illegal parameter: " + illegalParameter);
}
}
if (!getJdbcUrl().startsWith("jdbc:redshift")) {
DEException.throwException("Illegal jdbcUrl: " + getJdbcUrl());
}
return getJdbcUrl();
}
String jdbcUrl = "jdbc:redshift://HOSTNAME:PORT/DATABASE"

View File

@@ -1,5 +1,6 @@
package io.dataease.datasource.type;
import io.dataease.exception.DEException;
import io.dataease.extensions.datasource.vo.DatasourceConfiguration;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
@@ -18,6 +19,9 @@ public class Sqlserver extends DatasourceConfiguration {
public String getJdbc() {
if(StringUtils.isNoneEmpty(getUrlType()) && !getUrlType().equalsIgnoreCase("hostName")){
if (!getJdbcUrl().startsWith("jdbc:sqlserver")) {
DEException.throwException("Illegal jdbcUrl: " + getJdbcUrl());
}
return getJdbcUrl();
}
if (StringUtils.isEmpty(extraParams.trim())) {