Skip to content

Commit 335fe2d

Browse files
committed
temporary debugging statements
1 parent e384a3f commit 335fe2d

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

src/main/java/org/jenkinsci/plugins/workflow/libs/LibraryAdder.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,12 @@
2424

2525
package org.jenkinsci.plugins.workflow.libs;
2626

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;
3427
import java.io.File;
3528
import java.io.IOException;
3629
import java.io.InputStream;
3730
import java.net.URL;
31+
import java.nio.file.Files;
32+
import java.nio.file.Path;
3833
import java.util.ArrayList;
3934
import java.util.Base64;
4035
import java.util.Collection;
@@ -43,12 +38,10 @@
4338
import java.util.LinkedHashMap;
4439
import java.util.List;
4540
import java.util.Map;
46-
import java.util.Set;
4741
import java.util.TreeMap;
4842
import java.util.logging.Level;
4943
import java.util.logging.Logger;
50-
import edu.umd.cs.findbugs.annotations.CheckForNull;
51-
import edu.umd.cs.findbugs.annotations.NonNull;
44+
5245
import org.apache.commons.io.IOUtils;
5346
import org.jenkinsci.plugins.workflow.cps.CpsFlowExecution;
5447
import org.jenkinsci.plugins.workflow.cps.GlobalVariable;
@@ -58,6 +51,16 @@
5851
import org.jenkinsci.plugins.workflow.cps.replay.ReplayAction;
5952
import org.jenkinsci.plugins.workflow.flow.FlowCopier;
6053

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+
6164
/**
6265
* Given {@link LibraryResolver}, actually adds to the Groovy classpath.
6366
*/
@@ -257,7 +260,15 @@ static List<URL> retrieve(@NonNull LibraryRecord record, @NonNull LibraryRetriev
257260
for (LibraryRecord library : action.getLibraries()) {
258261
FilePath libResources = libs.child(library.getDirectoryName() + "/resources/");
259262
FilePath f = libResources.child(name);
260-
if (!new File(f.getRemote()).getCanonicalFile().toPath().startsWith(new File(libResources.getRemote()).getCanonicalPath())) {
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())) {
261272
throw new AbortException(name + " references a file that is not contained within the library: " + library.name);
262273
} else if (f.exists()) {
263274
resources.put(library.name, readResource(f, encoding));

0 commit comments

Comments
 (0)