|
24 | 24 |
|
25 | 25 | package org.jenkinsci.plugins.workflow.libs;
|
26 | 26 |
|
| 27 | +import hudson.AbortException; |
| 28 | +import hudson.Extension; |
| 29 | +import hudson.ExtensionList; |
| 30 | +import hudson.FilePath; |
| 31 | +import hudson.model.Queue; |
| 32 | +import hudson.model.Run; |
| 33 | +import hudson.model.TaskListener; |
27 | 34 | import java.io.File;
|
28 | 35 | import java.io.IOException;
|
29 | 36 | import java.io.InputStream;
|
30 | 37 | import java.net.URL;
|
31 |
| -import java.nio.file.Files; |
32 |
| -import java.nio.file.Path; |
33 | 38 | import java.util.ArrayList;
|
34 | 39 | import java.util.Base64;
|
35 | 40 | import java.util.Collection;
|
|
38 | 43 | import java.util.LinkedHashMap;
|
39 | 44 | import java.util.List;
|
40 | 45 | import java.util.Map;
|
| 46 | +import java.util.Set; |
41 | 47 | import java.util.TreeMap;
|
42 | 48 | import java.util.logging.Level;
|
43 | 49 | import java.util.logging.Logger;
|
44 |
| - |
| 50 | +import edu.umd.cs.findbugs.annotations.CheckForNull; |
| 51 | +import edu.umd.cs.findbugs.annotations.NonNull; |
45 | 52 | import org.apache.commons.io.IOUtils;
|
46 | 53 | import org.jenkinsci.plugins.workflow.cps.CpsFlowExecution;
|
47 | 54 | import org.jenkinsci.plugins.workflow.cps.GlobalVariable;
|
|
51 | 58 | import org.jenkinsci.plugins.workflow.cps.replay.ReplayAction;
|
52 | 59 | import org.jenkinsci.plugins.workflow.flow.FlowCopier;
|
53 | 60 |
|
54 |
| -import edu.umd.cs.findbugs.annotations.CheckForNull; |
55 |
| -import edu.umd.cs.findbugs.annotations.NonNull; |
56 |
| -import hudson.AbortException; |
57 |
| -import hudson.Extension; |
58 |
| -import hudson.ExtensionList; |
59 |
| -import hudson.FilePath; |
60 |
| -import hudson.model.Queue; |
61 |
| -import hudson.model.Run; |
62 |
| -import hudson.model.TaskListener; |
63 |
| - |
64 | 61 | /**
|
65 | 62 | * Given {@link LibraryResolver}, actually adds to the Groovy classpath.
|
66 | 63 | */
|
@@ -260,15 +257,7 @@ static List<URL> retrieve(@NonNull LibraryRecord record, @NonNull LibraryRetriev
|
260 | 257 | for (LibraryRecord library : action.getLibraries()) {
|
261 | 258 | FilePath libResources = libs.child(library.getDirectoryName() + "/resources/");
|
262 | 259 | FilePath f = libResources.child(name);
|
263 |
| - LOGGER.info("path: " + new File(f.getRemote()).getCanonicalFile().toPath()); |
264 |
| - LOGGER.info("library path: " + new File(libResources.getRemote()).getCanonicalPath()); |
265 |
| - File requestedFile = new File(f.getRemote()).getCanonicalFile(); |
266 |
| - Path requestedFilePath = requestedFile.toPath(); |
267 |
| - if (Files.isSymbolicLink(requestedFilePath)) { |
268 |
| - requestedFilePath = Files.readSymbolicLink(requestedFilePath).toFile().getCanonicalFile().toPath(); |
269 |
| - } |
270 |
| - LOGGER.info("requested file path: " +requestedFilePath); |
271 |
| - if (!requestedFilePath.startsWith(new File(libResources.getRemote()).getCanonicalPath())) { |
| 260 | + if (!new File(f.getRemote()).getCanonicalFile().toPath().startsWith(new File(libResources.getRemote()).getCanonicalPath())) { |
272 | 261 | throw new AbortException(name + " references a file that is not contained within the library: " + library.name);
|
273 | 262 | } else if (f.exists()) {
|
274 | 263 | resources.put(library.name, readResource(f, encoding));
|
|
0 commit comments