| 
33 | 33 | import java.io.OutputStream;  | 
34 | 34 | import java.nio.file.Files;  | 
35 | 35 | import java.nio.file.Path;  | 
36 |  | -import java.nio.file.Paths;  | 
37 | 36 | import java.util.Arrays;  | 
38 | 37 | import java.util.HashMap;  | 
39 | 38 | import java.util.Map;  | 
40 | 39 | import java.util.Properties;  | 
41 | 40 | 
 
  | 
42 | 41 | import static com.walmartlabs.concord.common.IOUtils.assertInPath;  | 
43 | 42 | 
 
  | 
44 |  | -//import static com.walmartlabs.concord.common.IOUtils.assertInPath;  | 
45 |  | - | 
46 | 43 | public class ResourceTaskCommon {  | 
47 | 44 | 
 
  | 
48 | 45 |     private static final String RESOURCE_PREFIX = "resource_";  | 
@@ -236,17 +233,16 @@ public static String prettyPrintYaml(Object value, int indent) throws IOExceptio  | 
236 | 233 |         return s;  | 
237 | 234 |     }  | 
238 | 235 | 
 
  | 
239 |  | -    private Path normalizePath(String path) throws IOException {  | 
240 |  | -        Path p = Paths.get(path);  | 
241 |  | -        assertWorkDirPath(path);  | 
242 |  | -        if (p.isAbsolute()) {  | 
243 |  | -            return p;  | 
244 |  | -        }  | 
245 |  | -        return workDir.resolve(path);  | 
 | 236 | +    private Path normalizePath(String path) {  | 
 | 237 | +        return assertWorkDirPath(path);  | 
246 | 238 |     }  | 
247 | 239 | 
 
  | 
248 |  | -    private Path assertWorkDirPath(String path) throws IOException {  | 
249 |  | -        return assertInPath(workDir, path);  | 
 | 240 | +    private Path assertWorkDirPath(String path) {  | 
 | 241 | +        try {  | 
 | 242 | +            return assertInPath(workDir,path);  | 
 | 243 | +        } catch (IOException ex) {  | 
 | 244 | +            throw new IllegalArgumentException("Not authorized to access file outside of working directory: " + path);  | 
 | 245 | +        }  | 
250 | 246 |     }  | 
251 | 247 | 
 
  | 
252 | 248 |     private static ObjectWriter createYamlWriter() {  | 
 | 
0 commit comments