diff --git a/pom.xml b/pom.xml
index 2b12a89383..e4a3c3ba39 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,6 +58,7 @@
3.11
4.4
1.20
+ 2.8.0
1.15
2.3.5.RELEASE
5.2.9.RELEASE
@@ -113,6 +114,11 @@
commons-compress
${apache.commons.compress}
+
+ commons-io
+ commons-io
+ ${apache.commons.io}
+
com.github.ben-manes.caffeine
caffeine
diff --git a/util/pom.xml b/util/pom.xml
index 7077c8a95c..c92a4b2c01 100644
--- a/util/pom.xml
+++ b/util/pom.xml
@@ -46,6 +46,10 @@
org.apache.commons
commons-lang3
+
+ commons-io
+ commons-io
+
org.slf4j
slf4j-api
diff --git a/util/src/main/java/io/kubernetes/client/Copy.java b/util/src/main/java/io/kubernetes/client/Copy.java
index 1c21dd655c..182aaea848 100644
--- a/util/src/main/java/io/kubernetes/client/Copy.java
+++ b/util/src/main/java/io/kubernetes/client/Copy.java
@@ -42,6 +42,7 @@
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
+import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -188,7 +189,11 @@ public Future copyDirectoryFromPodAsync(
log.error("Can't read: " + entry);
continue;
}
- File f = new File(destination.toFile(), entry.getName());
+ String normalName = FilenameUtils.normalize(entry.getName());
+ if (normalName == null) {
+ throw new IOException("Invalid entry: " + entry.getName());
+ }
+ File f = new File(destination.toFile(), normalName);
if (entry.isDirectory()) {
if (!f.isDirectory() && !f.mkdirs()) {
throw new IOException("create directory failed: " + f);