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 #1141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.io.File;
import java.io.InputStreamReader;
import java.net.URI;
import java.nio.file.Files;
import java.util.*;

/**
Expand Down Expand Up @@ -551,8 +552,8 @@ else if (Figure instanceof House) {
protected <T> T processThroughXml(T object) throws Exception {
JAXBContext context = JAXBContext.newInstance(object.getClass());
Marshaller marshaller = context.createMarshaller();
File in = File.createTempFile(object.getClass().getName(), ".xml", this.tempDir);
File out = File.createTempFile(object.getClass().getName(), ".xml", this.tempDir);
File in = Files.createTempFile(this.tempDir.toPath(), object.getClass().getName(), ".xml").toFile();
File out = Files.createTempFile(this.tempDir.toPath(), object.getClass().getName(), ".xml").toFile();
marshaller.marshal(object, in);
Process process = new ProcessBuilder("mono", this.exe.getAbsolutePath(), convertClassname(object.getClass().getName()), in.getAbsolutePath(), out.getAbsolutePath())
.redirectErrorStream(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import junit.framework.TestCase;

import java.io.*;
import java.nio.file.Files;
import java.util.*;

import com.webcohesion.enunciate.examples.javascript_client.schema.*;
Expand Down Expand Up @@ -523,8 +524,8 @@ else if (Figure instanceof House) {
protected <T> T processThroughJson(T object) throws Exception {
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();

File in = File.createTempFile(object.getClass().getName() + "In", ".json", this.tempDir);
File out = File.createTempFile(object.getClass().getName() + "Out", ".json", this.tempDir);
File in = Files.createTempFile(this.tempDir.toPath(), object.getClass().getName() + "In", ".json").toFile();
File out = Files.createTempFile(this.tempDir.toPath(), object.getClass().getName() + "Out", ".json").toFile();
FileOutputStream fos = new FileOutputStream(in);
provider.writeTo(object, object.getClass(), null, null, null, null, fos);
fos.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@
import java.io.File;
import java.io.InputStreamReader;
import java.net.URI;
import java.nio.file.Files;
import java.util.*;

/**
/**
* Makes sure Objecitve C serialization is working correctly.
*
* @author Ryan Heaton
Expand Down Expand Up @@ -654,8 +655,8 @@ else if (Figure instanceof House) {
protected <T> T processThroughXml(T object) throws Exception {
JAXBContext context = JAXBContext.newInstance(object.getClass());
Marshaller marshaller = context.createMarshaller();
File in = File.createTempFile(getName(), ".in.xml", this.tempDir);
File out = File.createTempFile(getName(), ".out.xml", this.tempDir);
File in = Files.createTempFile(this.tempDir.toPath(), getName(), ".in.xml").toFile();
File out = Files.createTempFile(this.tempDir.toPath(), getName(), ".out.xml").toFile();
marshaller.marshal(object, in);
// System.out.printf("%s %s %s %s\n", this.exe.getAbsolutePath(), object.getClass().getSimpleName().toLowerCase(), in.getAbsolutePath(), out.getAbsolutePath());
Process process = new ProcessBuilder(this.exe.getAbsolutePath(), object.getClass().getSimpleName().toLowerCase(), in.getAbsolutePath(), out.getAbsolutePath())
Expand Down Expand Up @@ -694,4 +695,4 @@ protected String packageToModule(String pckg) {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import junit.framework.TestCase;

import java.io.*;
import java.nio.file.Files;
import java.util.*;

import com.webcohesion.enunciate.examples.php_json_client.schema.*;
Expand Down Expand Up @@ -523,8 +524,8 @@ else if (Figure instanceof House) {
protected <T> T processThroughJson(T object) throws Exception {
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();

File in = File.createTempFile(object.getClass().getName() + "In", ".json", this.tempDir);
File out = File.createTempFile(object.getClass().getName() + "Out", ".json", this.tempDir);
File in = Files.createTempFile(this.tempDir.toPath(), object.getClass().getName() + "In", ".json").toFile();
File out = Files.createTempFile(this.tempDir.toPath(), object.getClass().getName() + "Out", ".json").toFile();
FileOutputStream fos = new FileOutputStream(in);
provider.writeTo(object, object.getClass(), null, null, null, null, fos);
fos.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.util.*;

/**
Expand Down Expand Up @@ -527,8 +528,8 @@ else if (Figure instanceof House) {
protected <T> T processThroughXml(T object) throws Exception {
JAXBContext context = JAXBContext.newInstance(object.getClass());
Marshaller marshaller = context.createMarshaller();
File in = File.createTempFile(object.getClass().getName() + "In", ".xml", this.tempDir);
File out = File.createTempFile(object.getClass().getName() + "Out", ".xml", this.tempDir);
File in = Files.createTempFile(this.tempDir.toPath(), object.getClass().getName() + "In", ".xml").toFile();
File out = Files.createTempFile(this.tempDir.toPath(), object.getClass().getName() + "Out", ".xml").toFile();
FileOutputStream fos = new FileOutputStream(in);
marshaller.marshal(object, in);
fos.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import junit.framework.TestCase;

import java.io.*;
import java.nio.file.Files;
import java.util.*;

/**
Expand Down Expand Up @@ -522,8 +523,8 @@ else if (Figure instanceof House) {
protected <T> T processThroughJson(T object) throws Exception {
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();

File in = File.createTempFile(object.getClass().getName() + "In", ".json", this.tempDir);
File out = File.createTempFile(object.getClass().getName() + "Out", ".json", this.tempDir);
File in = Files.createTempFile(this.tempDir.toPath(), object.getClass().getName() + "In", ".json").toFile();
File out = Files.createTempFile(this.tempDir.toPath(), object.getClass().getName() + "Out", ".json").toFile();
FileOutputStream fos = new FileOutputStream(in);
provider.writeTo(object, object.getClass(), null, null, null, null, fos);
fos.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.util.*;

/**
Expand Down Expand Up @@ -681,7 +682,7 @@ protected void loadConfig(Enunciate config, File configFile) throws IOException,
}
else {
this.buildDir.mkdirs();
File filteredConfig = File.createTempFile("enunciateConfig", ".xml", this.buildDir);
File filteredConfig = Files.createTempFile(this.buildDir.toPath(), "enunciateConfig", ".xml").toFile();
getLog().debug("[ENUNCIATE] Filtering " + configFile + " to " + filteredConfig + "...");
this.configFilter.copyFile(configFile, filteredConfig, true, this.project, new ArrayList(), true, "utf-8", this.session);
config.loadConfiguration(filteredConfig); //load the filtered configuration...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.nio.file.Files;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -404,7 +405,7 @@ private File generatePomFile(Model model)
throws MojoExecutionException {
FileWriter fw = null;
try {
File tempFile = File.createTempFile("mvninstall", ".pom");
File tempFile = Files.createTempFile("mvninstall", ".pom").toFile();
tempFile.deleteOnExit();


Expand Down