Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins/tasks/resource/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<artifactId>concord-runtime-sdk-v2</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.walmartlabs.concord</groupId>
<artifactId>concord-common</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import static com.walmartlabs.concord.common.IOUtils.assertInPath;

public class ResourceTaskCommon {

private static final String RESOURCE_PREFIX = "resource_";
Expand Down Expand Up @@ -233,25 +234,15 @@ public static String prettyPrintYaml(Object value, int indent) throws IOExceptio
}

private Path normalizePath(String path) {
Path p = Paths.get(path);
if (p.isAbsolute()) {
return p;
}
return workDir.resolve(path);
return assertWorkDirPath(path);
}

private Path assertWorkDirPath(String path) {
if (path == null) {
throw new IllegalArgumentException("Path cannot be null");
}
Path dst = Paths.get(path);
if (!dst.isAbsolute()) {
dst = workDir.resolve(path).normalize().toAbsolutePath();
}
if (!dst.startsWith(workDir)) {
throw new IllegalArgumentException("Invalid path: " + path);
try {
return assertInPath(workDir,path);
} catch (IOException ex) {
throw new IllegalArgumentException("Not authorized to access file outside of working directory: " + path);
}
return dst;
}

private static ObjectWriter createYamlWriter() {
Expand Down
Loading