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

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 @@ -12,6 +12,7 @@
import edu.isi.nlp.evaluation.FMeasureCounts;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Map;
import org.junit.Test;

Expand All @@ -25,7 +26,7 @@ public class TestSerialization {
public void testFMeasureCounts() throws IOException {
final Map<String, FMeasureCounts> foo =
ImmutableMap.of("Hello", FMeasureCounts.fromTPFPFN(1, 2, 3));
final File tmp = File.createTempFile("foo", "bar");
final File tmp = Files.createTempFile("foo", "bar").toFile();
tmp.deleteOnExit();

assertEquals(foo, JacksonTestUtils.roundTripThroughSerializer(foo, serializer));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Map;

/**
Expand All @@ -35,7 +36,7 @@ private PlotBundle(
public String commandsWritingDataTo(File dataDirectory) throws IOException {
final Map<DatafileReference, File> refsToFiles = Maps.newHashMap();
for (final DatafileReference datafileReference : datafileReferences) {
final File randomFile = File.createTempFile("plotBundle", ".dat", dataDirectory);
final File randomFile = Files.createTempFile(dataDirectory.toPath(), "plotBundle", ".dat").toFile();
randomFile.deleteOnExit();
refsToFiles.put(datafileReference, randomFile);
Files.asCharSink(randomFile, Charsets.UTF_8).write(datafileReference.data);
Expand Down
3 changes: 2 additions & 1 deletion gnuplot-util/src/main/java/edu/isi/nlp/graphviz/DotRenderer.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.nio.file.Files;
import javax.inject.Inject;
import javax.inject.Qualifier;
import org.slf4j.Logger;
Expand All @@ -41,7 +42,7 @@ public static DotRenderer createForDotExecutable(File dotBinary) {
}

public void renderToFile(Graph graph, File outputFile) throws IOException, InterruptedException {
final File dotCommands = File.createTempFile("dotRenderer", ".dot");
final File dotCommands = Files.createTempFile("dotRenderer", ".dot").toFile();
// dotCommands.deleteOnExit();;
Files.asCharSink(dotCommands, Charsets.UTF_8).write(graph.toDot());
renderToFile(dotCommands, outputFile);
Expand Down