Skip to content

Commit 6d844ea

Browse files
committed
Normalize local path in Kyuubi server
Authored-by: Hiroki Egawa <hiegawa@lycorp.co.jp> Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
1 parent 84be226 commit 6d844ea

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KyuubiApplicationManager.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package org.apache.kyuubi.engine
1919

2020
import java.io.File
2121
import java.net.{URI, URISyntaxException}
22-
import java.nio.file.{Files, Path}
22+
import java.nio.file.{Files, Path, Paths}
2323
import java.util.Locale
2424

2525
import scala.util.control.NonFatal
@@ -163,7 +163,7 @@ object KyuubiApplicationManager {
163163
s"Relative path ${uri.getPath} is not allowed, please use absolute path.")
164164
}
165165

166-
if (!localDirAllowList.exists(uri.getPath.startsWith(_))) {
166+
if (!localDirAllowList.exists(Paths.get(uri.getPath).normalize.startsWith(_))) {
167167
throw new KyuubiException(
168168
s"The file ${uri.getPath} to access is not in the local dir allow list" +
169169
s" [${localDirAllowList.mkString(",")}].")

kyuubi-server/src/test/scala/org/apache/kyuubi/engine/KyuubiApplicationManagerSuite.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class KyuubiApplicationManagerSuite extends KyuubiFunSuite {
3838
assert(e.getMessage.contains("is not in the local dir allow list"))
3939
KyuubiApplicationManager.checkApplicationAccessPath(path, noLocalDirLimitConf)
4040

41+
path = "/apache/kyuubi/../a.jar"
42+
e = intercept[KyuubiException] {
43+
KyuubiApplicationManager.checkApplicationAccessPath(path, localDirLimitConf)
44+
}
45+
assert(e.getMessage.contains("is not in the local dir allow list"))
46+
KyuubiApplicationManager.checkApplicationAccessPath(path, noLocalDirLimitConf)
47+
4148
path = "hdfs:/apache/kyuubijar"
4249
KyuubiApplicationManager.checkApplicationAccessPath(path, localDirLimitConf)
4350
KyuubiApplicationManager.checkApplicationAccessPath(path, noLocalDirLimitConf)

0 commit comments

Comments
 (0)