Skip to content

Commit 9353662

Browse files
committed
another dangerous query param
1 parent 8c21863 commit 9353662

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ public class JDBCInterpreter extends KerberosInterpreter {
156156
"KerberosConfigPath", "KerberosKeytabPath", "KerberosCredentialCachePath",
157157
"extraCredentials", "roles", "sessionProperties"));
158158

159+
private static final String ALLOW_LOAD_LOCAL = "allowLoadLocal";
160+
159161
private static final String ALLOW_LOAD_LOCAL_IN_FILE_NAME = "allowLoadLocalInfile";
160162

161163
private static final String AUTO_DESERIALIZE = "autoDeserialize";
@@ -594,7 +596,8 @@ private void validateConnectionUrl(String url) {
594596
String decodedUrl = URLDecoder.decode(url, StandardCharsets.UTF_8);
595597
Map<String, String> params = parseUrlParameters(decodedUrl);
596598

597-
if (containsKeyIgnoreCase(params, ALLOW_LOAD_LOCAL_IN_FILE_NAME) ||
599+
if (containsKeyIgnoreCase(params, ALLOW_LOAD_LOCAL) ||
600+
containsKeyIgnoreCase(params, ALLOW_LOAD_LOCAL_IN_FILE_NAME) ||
598601
containsKeyIgnoreCase(params, AUTO_DESERIALIZE) ||
599602
containsKeyIgnoreCase(params, ALLOW_LOCAL_IN_FILE_NAME) ||
600603
containsKeyIgnoreCase(params, ALLOW_URL_IN_LOCAL_IN_FILE_NAME)) {

jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ void testSplitSqlQueryWithComments() throws IOException,
750750
@Test
751751
void testValidateConnectionUrl() throws IOException, InterpreterException {
752752
Properties properties = new Properties();
753+
// it easier to unit test with H2 but this is really a MySQL issue (and maybe MariaDB too)
753754
properties.setProperty("default.driver", "org.h2.Driver");
754755
properties.setProperty("default.url", getJdbcConnection() + ";allowLoadLocalInfile=true");
755756
properties.setProperty("default.user", "");
@@ -762,9 +763,26 @@ void testValidateConnectionUrl() throws IOException, InterpreterException {
762763
interpreterResult.message().get(0).getData());
763764
}
764765

766+
@Test
767+
void testValidateConnectionUrlAllowLoadLocal() throws IOException, InterpreterException {
768+
Properties properties = new Properties();
769+
// it easier to unit test with H2 but this is really a MySQL issue (and maybe MariaDB too)
770+
properties.setProperty("default.driver", "org.h2.Driver");
771+
properties.setProperty("default.url", getJdbcConnection() + ";allowLoadLocal=true");
772+
properties.setProperty("default.user", "");
773+
properties.setProperty("default.password", "");
774+
JDBCInterpreter jdbcInterpreter = new JDBCInterpreter(properties);
775+
jdbcInterpreter.open();
776+
InterpreterResult interpreterResult = jdbcInterpreter.interpret("SELECT 1", context);
777+
assertEquals(InterpreterResult.Code.ERROR, interpreterResult.code());
778+
assertEquals("Connection URL contains improper configuration",
779+
interpreterResult.message().get(0).getData());
780+
}
781+
765782
@Test
766783
void testValidateConnectionUrlEncoded() throws IOException, InterpreterException {
767784
Properties properties = new Properties();
785+
// it easier to unit test with H2 but this is really a MySQL issue (and maybe MariaDB too)
768786
properties.setProperty("default.driver", "org.h2.Driver");
769787
properties.setProperty("default.url", getJdbcConnection() + ";%61llowLoadLocalInfile=true");
770788
properties.setProperty("default.user", "");

0 commit comments

Comments
 (0)