Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SECURITY] Fix Temporary File Information Disclosure Vulnerability #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/test/java/org/jenkinsci/plugins/gogs/GogsWebHookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.file.Files;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -78,7 +79,7 @@ public void callDoIndexWithNullResponseMessageMustThrowException() throws IOExce
@Test
public void whenEmptyHeaderTypeMustReturnError() throws Exception {
//Prepare the SUT
File uniqueFile = File.createTempFile("webHookTest_", ".txt", new File("target"));
File uniqueFile = Files.createTempFile(new File("target").toPath(), "webHookTest_", ".txt").toFile();

StaplerRequest staplerRequest = Mockito.mock(RequestImpl.class);
StaplerResponse staplerResponse = Mockito.mock(ResponseImpl.class);
Expand All @@ -98,7 +99,7 @@ public void whenEmptyHeaderTypeMustReturnError() throws Exception {
@Test
public void whenWrongHeaderTypeMustReturnError() throws Exception {
//Prepare the SUT
File uniqueFile = File.createTempFile("webHookTest_", ".txt", new File("target"));
File uniqueFile = Files.createTempFile(new File("target").toPath(), "webHookTest_", ".txt").toFile();

StaplerRequest staplerRequest = Mockito.mock(RequestImpl.class);
StaplerResponse staplerResponse = Mockito.mock(ResponseImpl.class);
Expand Down Expand Up @@ -142,7 +143,7 @@ public void whenQueryStringIsNullMustThrowException() throws Exception {
@Test
public void whenNoJobInQueryStringMustReturnError() throws Exception {
//Prepare the SUT
File uniqueFile = File.createTempFile("webHookTest_", ".txt", new File("target"));
File uniqueFile = Files.createTempFile(new File("target").toPath(), "webHookTest_", ".txt").toFile();

StaplerRequest staplerRequest = Mockito.mock(RequestImpl.class);
StaplerResponse staplerResponse = Mockito.mock(ResponseImpl.class);
Expand All @@ -164,7 +165,7 @@ public void whenNoJobInQueryStringMustReturnError() throws Exception {
@Test
public void whenEmptyJobInQueryStringMustReturnError() throws Exception {
//Prepare the SUT
File uniqueFile = File.createTempFile("webHookTest_", ".txt", new File("target"));
File uniqueFile = Files.createTempFile(new File("target").toPath(), "webHookTest_", ".txt").toFile();

StaplerRequest staplerRequest = Mockito.mock(RequestImpl.class);
StaplerResponse staplerResponse = Mockito.mock(ResponseImpl.class);
Expand All @@ -186,7 +187,7 @@ public void whenEmptyJobInQueryStringMustReturnError() throws Exception {
@Test
public void whenEmptyJob2InQueryStringMustReturnError() throws Exception {
//Prepare the SUT
File uniqueFile = File.createTempFile("webHookTest_", ".txt", new File("target"));
File uniqueFile = Files.createTempFile(new File("target").toPath(), "webHookTest_", ".txt").toFile();

StaplerRequest staplerRequest = Mockito.mock(RequestImpl.class);
StaplerResponse staplerResponse = Mockito.mock(ResponseImpl.class);
Expand All @@ -208,7 +209,7 @@ public void whenEmptyJob2InQueryStringMustReturnError() throws Exception {
@Test
public void whenUriDoesNotContainUrlNameMustReturnError() throws Exception {
//Prepare the SUT
File uniqueFile = File.createTempFile("webHookTest_", ".txt", new File("target"));
File uniqueFile = Files.createTempFile(new File("target").toPath(), "webHookTest_", ".txt").toFile();

StaplerRequest staplerRequest = Mockito.mock(RequestImpl.class);
StaplerResponse staplerResponse = Mockito.mock(ResponseImpl.class);
Expand Down