Skip to content

Commit

Permalink
Merge pull request #1426 from brendandburns/apply
Browse files Browse the repository at this point in the history
Add path normalization for archive files.
  • Loading branch information
k8s-ci-robot committed Dec 11, 2020
2 parents 08c9a0f + ff16217 commit f46f2fa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -58,6 +58,7 @@
<apache.commons.lang3.version>3.11</apache.commons.lang3.version>
<apache.commons.collections4.version>4.4</apache.commons.collections4.version>
<apache.commons.compress>1.20</apache.commons.compress>
<apache.commons.io>2.8.0</apache.commons.io>
<common.codec.version>1.15</common.codec.version>
<spring.boot.version>2.3.5.RELEASE</spring.boot.version>
<spring.version>5.2.9.RELEASE</spring.version>
Expand Down Expand Up @@ -113,6 +114,11 @@
<artifactId>commons-compress</artifactId>
<version>${apache.commons.compress}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${apache.commons.io}</version>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions util/pom.xml
Expand Up @@ -46,6 +46,10 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
7 changes: 6 additions & 1 deletion util/src/main/java/io/kubernetes/client/Copy.java
Expand Up @@ -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;

Expand Down Expand Up @@ -188,7 +189,11 @@ public Future<Integer> 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);
Expand Down

0 comments on commit f46f2fa

Please sign in to comment.