From 162a70c8f0e5041f912167b00a03607bdc6d0bf5 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Thu, 25 May 2023 16:27:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A0=A1=E9=AA=8C=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../provider/datasource/JdbcProvider.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java b/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java index 2581ceb3d9..b34eb18df2 100644 --- a/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java +++ b/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java @@ -781,6 +781,9 @@ public class JdbcProvider extends DefaultJdbcProvider { case StarRocks: MysqlConfiguration mysqlConfiguration = new Gson().fromJson(datasource.getConfiguration(), MysqlConfiguration.class); mysqlConfiguration.getJdbc(); + if(!mysqlConfiguration.getDataBase().matches("^[0-9a-zA-Z_]{1,}$")){ + throw new Exception("Invalid database name"); + } break; case redshift: RedshiftConfiguration redshiftConfiguration = new Gson().fromJson(datasource.getConfiguration(), RedshiftConfiguration.class); @@ -791,6 +794,48 @@ public class JdbcProvider extends DefaultJdbcProvider { throw new Exception("Invalid database name"); } break; + case sqlServer: + SqlServerConfiguration sqlServerConfiguration = new Gson().fromJson(datasource.getConfiguration(), SqlServerConfiguration.class); + if(!sqlServerConfiguration.getDataBase().matches("^[0-9a-zA-Z_]{1,}$")){ + throw new Exception("Invalid database name"); + } + break; + case pg: + PgConfiguration pgConfiguration = new Gson().fromJson(datasource.getConfiguration(), PgConfiguration.class); + if(!pgConfiguration.getDataBase().matches("^[0-9a-zA-Z_]{1,}$")){ + throw new Exception("Invalid database name"); + } + break; + case oracle: + OracleConfiguration oracleConfiguration = new Gson().fromJson(datasource.getConfiguration(), OracleConfiguration.class); + if(!oracleConfiguration.getDataBase().matches("^[0-9a-zA-Z_]{1,}$")){ + throw new Exception("Invalid database name"); + } + break; + case mongo: + MongodbConfiguration mongodbConfiguration = new Gson().fromJson(datasource.getConfiguration(), MongodbConfiguration.class); + if(!mongodbConfiguration.getDataBase().matches("^[0-9a-zA-Z_]{1,}$")){ + throw new Exception("Invalid database name"); + } + break; + case impala: + ImpalaConfiguration impalaConfiguration = new Gson().fromJson(datasource.getConfiguration(), ImpalaConfiguration.class); + if(!impalaConfiguration.getDataBase().matches("^[0-9a-zA-Z_]{1,}$")){ + throw new Exception("Invalid database name"); + } + break; + case hive: + HiveConfiguration hiveConfiguration = new Gson().fromJson(datasource.getConfiguration(), HiveConfiguration.class); + if(!hiveConfiguration.getDataBase().matches("^[0-9a-zA-Z_]{1,}$")){ + throw new Exception("Invalid database name"); + } + break; + case db2: + Db2Configuration db2Configuration = new Gson().fromJson(datasource.getConfiguration(), Db2Configuration.class); + if(!db2Configuration.getDataBase().matches("^[0-9a-zA-Z_]{1,}$")){ + throw new Exception("Invalid database name"); + } + break; default: break; }