Skip to content

Commit 6bef90f

Browse files
Add path normalization for archive files.
1 parent ffb7dee commit 6bef90f

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<apache.commons.lang3.version>3.11</apache.commons.lang3.version>
5858
<apache.commons.collections4.version>4.4</apache.commons.collections4.version>
5959
<apache.commons.compress>1.20</apache.commons.compress>
60+
<apache.commons.io>2.8.0</apache.commons.io>
6061
<common.codec.version>1.15</common.codec.version>
6162
<spring.boot.version>2.3.5.RELEASE</spring.boot.version>
6263
<spring.version>5.2.9.RELEASE</spring.version>
@@ -112,6 +113,11 @@
112113
<artifactId>commons-compress</artifactId>
113114
<version>${apache.commons.compress}</version>
114115
</dependency>
116+
<dependency>
117+
<groupId>commons-io</groupId>
118+
<artifactId>commons-io</artifactId>
119+
<version>${apache.commons.io}</version>
120+
</dependency>
115121
<dependency>
116122
<groupId>com.google.guava</groupId>
117123
<artifactId>guava</artifactId>

util/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
<groupId>org.apache.commons</groupId>
4747
<artifactId>commons-lang3</artifactId>
4848
</dependency>
49+
<dependency>
50+
<groupId>commons-io</groupId>
51+
<artifactId>commons-io</artifactId>
52+
</dependency>
4953
<dependency>
5054
<groupId>com.google.guava</groupId>
5155
<artifactId>guava</artifactId>

util/src/main/java/io/kubernetes/client/Copy.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
4343
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
4444
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
45+
import org.apache.commons.io.FilenameUtils;
4546
import org.slf4j.Logger;
4647
import org.slf4j.LoggerFactory;
4748

@@ -188,7 +189,11 @@ public Future<Integer> copyDirectoryFromPodAsync(
188189
log.error("Can't read: " + entry);
189190
continue;
190191
}
191-
File f = new File(destination.toFile(), entry.getName());
192+
String normalName = FilenameUtils.normalize(entry.getName());
193+
if (normalName == null) {
194+
throw new IOException("Invalid entry: " + entry.getName());
195+
}
196+
File f = new File(destination.toFile(), normalName);
192197
if (entry.isDirectory()) {
193198
if (!f.isDirectory() && !f.mkdirs()) {
194199
throw new IOException("create directory failed: " + f);

0 commit comments

Comments
 (0)