From 0972980187b8ab204771ba2608ed7dd1b9e7b4ef Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Wed, 27 Jul 2022 16:35:29 +0000 Subject: [PATCH] vuln-fix: Temporary Directory Hijacking or Information Disclosure This fixes either Temporary Directory Hijacking, or Temporary Directory Local Information Disclosure. Weakness: CWE-379: Creation of Temporary File in Directory with Insecure Permissions Severity: High CVSSS: 7.3 Detection: CodeQL & OpenRewrite (https://public.moderne.io/recipes/org.openrewrite.java.security.UseFilesCreateTempDirectory) Reported-by: Jonathan Leitschuh Signed-off-by: Jonathan Leitschuh Bug-tracker: https://github.com/JLLeitschuh/security-research/issues/10 Co-authored-by: Moderne --- src/test/java/org/jenkinsci/plugins/sma/SMAPackageTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/sma/SMAPackageTest.java b/src/test/java/org/jenkinsci/plugins/sma/SMAPackageTest.java index fc29d16..20c4048 100644 --- a/src/test/java/org/jenkinsci/plugins/sma/SMAPackageTest.java +++ b/src/test/java/org/jenkinsci/plugins/sma/SMAPackageTest.java @@ -7,6 +7,7 @@ import org.junit.Test; import java.io.File; +import java.nio.file.Files; import java.util.Arrays; import java.util.List; @@ -24,9 +25,7 @@ public class SMAPackageTest public void setUp() throws Exception { //Setup the fake workspace and package manifest - testWorkspace = File.createTempFile("TestWorkspace", ""); - testWorkspace.delete(); - testWorkspace.mkdirs(); + testWorkspace = Files.createTempDirectory("TestWorkspace").toFile(); testWorkspacePath = testWorkspace.getPath(); String emptyString = "";