diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java index 0ac7763ba7..a030762457 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java @@ -213,6 +213,7 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource baseDataSourceParamDTO.setId(dataSource.getId()); baseDataSourceParamDTO.setName(dataSource.getName()); baseDataSourceParamDTO.setNote(dataSource.getNote()); + baseDataSourceParamDTO.setPassword(getHiddenPassword()); return baseDataSourceParamDTO; } diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessor.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessor.java index 856ae1c9e9..db357e9d5c 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessor.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessor.java @@ -69,7 +69,8 @@ public abstract class AbstractDataSourceProcessor implements DataSourceProcessor * @param host datasource host */ protected void checkHost(String host) { - if (!IPV4_PATTERN.matcher(host).matches() || !IPV6_PATTERN.matcher(host).matches()) { + if (com.google.common.net.InetAddresses.isInetAddress(host)) { + } else if (!IPV4_PATTERN.matcher(host).matches() || !IPV6_PATTERN.matcher(host).matches()) { throw new IllegalArgumentException("datasource host illegal"); } } diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/utils/DataSourceUtilsTest.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/utils/DataSourceUtilsTest.java index 71f1b77449..7f3133d170 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/utils/DataSourceUtilsTest.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/utils/DataSourceUtilsTest.java @@ -47,7 +47,20 @@ public class DataSourceUtilsTest { @Test public void testCheckDatasourceParam() { MySQLDataSourceParamDTO mysqlDatasourceParamDTO = new MySQLDataSourceParamDTO(); - mysqlDatasourceParamDTO.setHost("localhost"); + mysqlDatasourceParamDTO.setHost("0.0.0.0"); + mysqlDatasourceParamDTO.setDatabase("default"); + Map other = new HashMap<>(); + other.put("serverTimezone", "Asia/Shanghai"); + other.put("queryTimeout", "-1"); + other.put("characterEncoding", "utf8"); + mysqlDatasourceParamDTO.setOther(other); + DataSourceUtils.checkDatasourceParam(mysqlDatasourceParamDTO); + Assertions.assertTrue(true); + } + @Test + public void testCheckIpv6DatasourceParam() { + MySQLDataSourceParamDTO mysqlDatasourceParamDTO = new MySQLDataSourceParamDTO(); + mysqlDatasourceParamDTO.setHost("0000:0000:0000::0000"); mysqlDatasourceParamDTO.setDatabase("default"); Map other = new HashMap<>(); other.put("serverTimezone", "Asia/Shanghai"); @@ -57,7 +70,6 @@ public class DataSourceUtilsTest { DataSourceUtils.checkDatasourceParam(mysqlDatasourceParamDTO); Assertions.assertTrue(true); } - @Test public void testBuildConnectionParams() { MySQLDataSourceParamDTO mysqlDatasourceParamDTO = new MySQLDataSourceParamDTO();