From cd99d11fe2ad558090d45b654ac3077328ac9784 Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Fri, 29 Jul 2022 15:14:54 -0400 Subject: [PATCH] [SECURITY] Fix Temporary Directory Information Disclosure Vulnerability in test (#567) Reported-by: Jonathan Leitschuh Signed-off-by: Jonathan Leitschuh Co-authored-by: Moderne --- src/test/java/hudson/remoting/PrefetchingTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/java/hudson/remoting/PrefetchingTest.java b/src/test/java/hudson/remoting/PrefetchingTest.java index bd44d3326..675ebeea0 100644 --- a/src/test/java/hudson/remoting/PrefetchingTest.java +++ b/src/test/java/hudson/remoting/PrefetchingTest.java @@ -11,6 +11,7 @@ import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; +import java.nio.file.Files; import java.util.concurrent.ExecutionException; import static org.hamcrest.MatcherAssert.assertThat; @@ -40,9 +41,7 @@ protected void setUp() throws Exception { new URL[] {toFile(jar1).toURI().toURL(), toFile(jar2).toURI().toURL()}, this.getClass().getClassLoader()); - dir = File.createTempFile("remoting", "cache"); - dir.delete(); - dir.mkdirs(); + dir = Files.createTempDirectory("remoting-cache").toFile(); channel.setJarCache(new FileSystemJarCache(dir, true)); channel.call(new JarCacherCallable());