Skip to content

Commit 25f22d4

Browse files
committed
[fix](jdbc) Keep empty jdbc_driver_secure_path as allow-all (backward compatible)
Revert the accidental empty-value semantic flip: an empty/blank jdbc_driver_secure_path again means "allow all", identical to "*", matching the documented contract. The structural-matching improvements still apply whenever the config is set to concrete paths (so a stray trailing ';' no longer opens everything), and all other hardening is unchanged. Removes one backward-incompatible behavior change for no real security loss, since "*" (allow-all) remains the default anyway.
1 parent 8fa7b3b commit 25f22d4

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎fe/fe-common/src/main/java/org/apache/doris/common/Config.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ public class Config extends ConfigBase {
159159
@ConfField(description = {"The safe path of the JDBC driver. When creating a JDBC Catalog, "
160160
+ "you can configure multiple files or network paths that are allowed to be used, "
161161
+ "separated by semicolons. "
162-
+ "The default is * to allow all. An empty value denies all scheme-qualified driver URLs "
163-
+ "(file://, http(s)://); bare jar file names resolved under jdbc_drivers_dir are always allowed."})
162+
+ "The default is * to allow all; if set to empty, it also means to allow all. "
163+
+ "When set to concrete paths, driver URLs are matched structurally (component-based), "
164+
+ "so path traversal and prefix confusion are rejected."})
164165
public static String jdbc_driver_secure_path = "*";
165166

166167
@ConfField(description = {"Functions that MySQL JDBC Catalog does not support pushing down"})

‎fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcResource.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,9 @@ public static String getFullDriverUrl(String driverUrl) throws IllegalArgumentEx
323323
return checkAndReturnDefaultDriverUrl(driverUrl);
324324
}
325325

326-
if ("*".equals(Config.jdbc_driver_secure_path)) {
326+
// "*" or an empty/blank value means allow all (the documented, backward-compatible contract).
327+
String securePath = Config.jdbc_driver_secure_path;
328+
if (securePath == null || securePath.trim().isEmpty() || "*".equals(securePath.trim())) {
327329
return driverUrl;
328330
}
329331

‎fe/fe-core/src/test/java/org/apache/doris/catalog/JdbcResourceTest.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,13 @@ public void testSecurePathRejectsRemoteUserInfoMismatch() {
361361
}
362362

363363
@Test
364-
public void testEmptySecurePathDeniesSchemeUrls() {
364+
public void testEmptySecurePathAllowsAll() {
365365
String saved = Config.jdbc_driver_secure_path;
366366
try {
367+
// Empty means allow-all, same as "*" (backward-compatible contract).
367368
Config.jdbc_driver_secure_path = "";
368-
Assert.assertThrows(IllegalArgumentException.class, () ->
369-
JdbcResource.getFullDriverUrl("file:///opt/doris/jdbc_drivers/x.jar"));
369+
String url = "file:///opt/doris/jdbc_drivers/x.jar";
370+
Assertions.assertDoesNotThrow(() -> Assert.assertEquals(url, JdbcResource.getFullDriverUrl(url)));
370371
} finally {
371372
Config.jdbc_driver_secure_path = saved;
372373
}

0 commit comments

Comments
 (0)