Browse Source

[bug] Exception when using host in ipv6 format (#14040)

* DB2 edit again, no username.

* [bug] db2's jdbcUrl should be like this "jdbc:db2://localhost:50000/sample:currentSchema=DB2INST1;characterEncoding=UTF-8;".should be ":"

* Update Db2DataSourceProcessor.java

* Update Db2DataSourceProcessorTest.java

* 【Bug】OracleSource edit again, ConnectionType is null

* when user inputs ipv6,checkhost will return "!IPV4_PATTERN.matcher(host).matches()";
I think we should use isInetAddress to check the host is isValid

* Update AbstractDataSourceProcessor.java

* Update DatabendDataSourceProcessorTest.java

last week other modified this

* Update MySQLDataSourceProcessorTest.java

* Update DataSourceUtilsTest.java

* Update MySQLDataSourceProcessorTest.java

* Update KyuubiDataSourceProcessorTest.java

* Update AbstractDataSourceProcessor.java

if host is ipv6 or ipv4 will OK; if not check other

* Update AbstractDataSourceProcessor.java

* Update AbstractDataSourceProcessor.java

* Update DataSourceUtilsTest.java

增加ipv6数据源验证

* [Bug] [dolphinscheduler-api] queryDataSource'password should be hidden.

---------

Co-authored-by: xiangzihao <460888207@qq.com>
Co-authored-by: Rick Cheng <rickchengx@gmail.com>
3.2.1-prepare
AliceXiaoLu 12 months ago committed by GitHub
parent
commit
cb5317f7ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
  2. 3
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessor.java
  3. 16
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/utils/DataSourceUtilsTest.java

1
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;
}

3
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");
}
}

16
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<String, String> 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<String, String> 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();

Loading…
Cancel
Save