Fix check value rather than key in AbstractDataSourceProcessor#checkOther (#15351)
This commit is contained in:
parent
5b6b0ceb31
commit
b73194bd35
|
|
@ -40,7 +40,6 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.dolphinscheduler</groupId>
|
||||
<artifactId>dolphinscheduler-task-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -92,12 +92,15 @@ public abstract class AbstractDataSourceProcessor implements DataSourceProcessor
|
|||
if (MapUtils.isEmpty(other)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Sets.intersection(other.keySet(), POSSIBLE_MALICIOUS_KEYS).isEmpty()) {
|
||||
throw new IllegalArgumentException("Other params include possible malicious keys.");
|
||||
}
|
||||
boolean paramsCheck = other.entrySet().stream().allMatch(p -> PARAMS_PATTER.matcher(p.getValue()).matches());
|
||||
if (!paramsCheck) {
|
||||
throw new IllegalArgumentException("datasource other params illegal");
|
||||
|
||||
for (Map.Entry<String, String> entry : other.entrySet()) {
|
||||
if (!PARAMS_PATTER.matcher(entry.getKey()).matches()) {
|
||||
throw new IllegalArgumentException("datasource other params: " + entry.getKey() + " illegal");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
|||
@ExtendWith(MockitoExtension.class)
|
||||
public class TrinoDataSourceProcessorTest {
|
||||
|
||||
private TrinoDataSourceProcessor TrinoDatasourceProcessor = new TrinoDataSourceProcessor();
|
||||
private final TrinoDataSourceProcessor TrinoDatasourceProcessor = new TrinoDataSourceProcessor();
|
||||
|
||||
@Test
|
||||
public void testCreateConnectionParams() {
|
||||
|
|
@ -92,4 +92,17 @@ public class TrinoDataSourceProcessorTest {
|
|||
Assertions.assertEquals(DataSourceConstants.TRINO_VALIDATION_QUERY,
|
||||
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…
Reference in New Issue