Browse Source

Fix check value rather than key in AbstractDataSourceProcessor#checkOther (#15351)

3.2.1-prepare
Wenjun Ruan 11 months ago committed by GitHub
parent
commit
b73194bd35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/pom.xml
  2. 9
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessor.java
  3. 15
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-trino/src/test/java/org/apache/dolphinscheduler/plugin/datasource/trino/param/TrinoDataSourceProcessorTest.java

1
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/pom.xml

@ -40,7 +40,6 @@
<dependency> <dependency>
<groupId>org.apache.dolphinscheduler</groupId> <groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-task-api</artifactId> <artifactId>dolphinscheduler-task-api</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

9
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessor.java

@ -92,12 +92,15 @@ public abstract class AbstractDataSourceProcessor implements DataSourceProcessor
if (MapUtils.isEmpty(other)) { if (MapUtils.isEmpty(other)) {
return; return;
} }
if (!Sets.intersection(other.keySet(), POSSIBLE_MALICIOUS_KEYS).isEmpty()) { if (!Sets.intersection(other.keySet(), POSSIBLE_MALICIOUS_KEYS).isEmpty()) {
throw new IllegalArgumentException("Other params include possible malicious keys."); throw new IllegalArgumentException("Other params include possible malicious keys.");
} }
boolean paramsCheck = other.entrySet().stream().allMatch(p -> PARAMS_PATTER.matcher(p.getValue()).matches());
if (!paramsCheck) { for (Map.Entry<String, String> entry : other.entrySet()) {
throw new IllegalArgumentException("datasource other params illegal"); if (!PARAMS_PATTER.matcher(entry.getKey()).matches()) {
throw new IllegalArgumentException("datasource other params: " + entry.getKey() + " illegal");
}
} }
} }

15
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-trino/src/test/java/org/apache/dolphinscheduler/plugin/datasource/trino/param/TrinoDataSourceProcessorTest.java

@ -34,7 +34,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TrinoDataSourceProcessorTest { public class TrinoDataSourceProcessorTest {
private TrinoDataSourceProcessor TrinoDatasourceProcessor = new TrinoDataSourceProcessor(); private final TrinoDataSourceProcessor TrinoDatasourceProcessor = new TrinoDataSourceProcessor();
@Test @Test
public void testCreateConnectionParams() { public void testCreateConnectionParams() {
@ -92,4 +92,17 @@ public class TrinoDataSourceProcessorTest {
Assertions.assertEquals(DataSourceConstants.TRINO_VALIDATION_QUERY, Assertions.assertEquals(DataSourceConstants.TRINO_VALIDATION_QUERY,
TrinoDatasourceProcessor.getValidationQuery()); TrinoDatasourceProcessor.getValidationQuery());
} }
@Test
public void testCheckDatasourceParam() {
Map<String, String> others = new HashMap<>();
others.put("SSL", "true");
others.put("SSLKeyStorePassword", "******");
others.put("SSLKeyStorePath", "/home/dolphinscheduler/trino.jks");
TrinoDataSourceParamDTO trinoDataSourceParamDTO = new TrinoDataSourceParamDTO();
trinoDataSourceParamDTO.setDatabase("dwh");
trinoDataSourceParamDTO.setHost("10.11.12.13");
trinoDataSourceParamDTO.setOther(others);
Assertions.assertDoesNotThrow(() -> TrinoDatasourceProcessor.checkDatasourceParam(trinoDataSourceParamDTO));
}
} }

Loading…
Cancel
Save