Skip to content

Commit 87a7d92

Browse files
committed
Update tests for recent security fixes for compatibility with Windows and Git plugin 4.10.3
1 parent ace0de3 commit 87a7d92

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/test/java/org/jenkinsci/plugins/workflow/libs/ResourceStepTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public class ResourceStepTest {
189189

190190
@Issue("SECURITY-2479")
191191
@Test public void symlinksInLibraryResourcesAreNotAllowedToEscapeWorkspaceContext() throws Exception {
192+
assumeFalse(Functions.isWindows()); // On Windows, the symlink is treated as a regular file, so there is no vulnerability, but the behavior is different.
192193
sampleRepo.init();
193194
sampleRepo.write("src/Stuff.groovy", "class Stuff {static def contents(script) {script.libraryResource 'master.key'}}");
194195
Path resourcesDir = Paths.get(sampleRepo.getRoot().getPath(), "resources");

src/test/java/org/jenkinsci/plugins/workflow/libs/SCMSourceRetrieverTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.io.IOException;
4040
import java.nio.charset.StandardCharsets;
4141
import java.nio.file.Files;
42+
import java.nio.file.Path;
4243
import java.util.Collections;
4344
import java.util.Iterator;
4445
import java.util.List;
@@ -425,7 +426,10 @@ public static class BasicSCMSource extends SCMSource {
425426
FileUtils.copyDirectory(new File(sampleRepo.getRoot(), ".git"), gitDirInSvnRepo);
426427
String jenkinsRootDir = r.jenkins.getRootDir().toString();
427428
// Add a Git post-checkout hook to the .git folder in the SVN repo.
428-
Files.write(gitDirInSvnRepo.toPath().resolve("hooks/post-checkout"), ("#!/bin/sh\ntouch '" + jenkinsRootDir + "/hook-executed'\n").getBytes(StandardCharsets.UTF_8));
429+
Path postCheckoutHook = gitDirInSvnRepo.toPath().resolve("hooks/post-checkout");
430+
// Always create hooks directory for compatibility with https://github.com/jenkinsci/git-plugin/pull/1207.
431+
Files.createDirectories(postCheckoutHook.getParent());
432+
Files.write(postCheckoutHook, ("#!/bin/sh\ntouch '" + jenkinsRootDir + "/hook-executed'\n").getBytes(StandardCharsets.UTF_8));
429433
sampleRepoSvn.svnkit("add", sampleRepoSvn.wc() + "/vars");
430434
sampleRepoSvn.svnkit("add", sampleRepoSvn.wc() + "/.git");
431435
sampleRepoSvn.svnkit("propset", "svn:executable", "ON", sampleRepoSvn.wc() + "/.git/hooks/post-checkout");

0 commit comments

Comments
 (0)