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

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 @@ -273,8 +273,7 @@ protected AuthenticatedURL.Token readAuthToken() {
protected void writeAuthToken(AuthenticatedURL.Token authToken) {
try {
String jvmName = ManagementFactory.getRuntimeMXBean().getName();
File tmpTokenFile = File.createTempFile(".oozie-auth-token", jvmName + "tmp",
new File(System.getProperty("user.home")));
File tmpTokenFile = Files.createTempFile(new File(System.getProperty("user.home")).toPath(), ".oozie-auth-token", jvmName + "tmp").toFile();
// just to be safe, if something goes wrong delete tmp file eventually
tmpTokenFile.deleteOnExit();
Writer writer = new OutputStreamWriter(new FileOutputStream(tmpTokenFile), StandardCharsets.UTF_8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.conf.Configuration;
Expand Down Expand Up @@ -327,7 +328,7 @@ public boolean evaluate() throws Exception {
assertNull(protoConf.get(WorkflowAppService.APP_LIB_PATH_LIST));

new File(getTestCaseDir() + "/lib").mkdirs();
File.createTempFile("parentLibrary", ".jar", new File(getTestCaseDir() + "/lib"));
Files.createTempFile(new File(getTestCaseDir() + "/lib").toPath(), "parentLibrary", ".jar").toFile();
conf.set(OozieClient.APP_PATH, workflowUri);
conf.set(OozieClient.USER_NAME, getTestUser());
conf.set("appName", "var-app-name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

public class TestGraphGenerator extends XTestCase {
private static final XLog LOG = XLog.getLog(TestGraphGenerator.class);
Expand Down Expand Up @@ -100,7 +101,7 @@ private WorkflowJobBean createSimpleWorkflow() {
private void generateAndAssertPng(final WorkflowJobBean workflowJob, final String path, final boolean showKill) {
File outputPng = null;
try {
outputPng = File.createTempFile("graph-output", path + ".png");
outputPng = Files.createTempFile("graph-output", path + ".png").toFile();
final String content = IOUtils.getResourceAsString(path, -1);
final GraphGenerator g = new GraphGenerator(content, workflowJob, showKill, new GraphvizRenderer());
g.write(new FileOutputStream(outputPng), OutputFormat.PNG);
Expand Down Expand Up @@ -131,7 +132,7 @@ public void testSimpleGraphDot() {

File outputDot = null;
try {
outputDot = File.createTempFile("graph-output", "graph-workflow-simple.dot");
outputDot = Files.createTempFile("graph-output", "graph-workflow-simple.dot").toFile();
final String content = IOUtils.getResourceAsString("graph-workflow-simple.xml", -1);
final GraphGenerator g = new GraphGenerator(content, jsonWFJob, true, new GraphvizRenderer());
g.write(new FileOutputStream(outputDot), OutputFormat.DOT);
Expand Down Expand Up @@ -165,7 +166,7 @@ public void testSimpleGraphSvg() {

File outputDot = null;
try {
outputDot = File.createTempFile("graph-output", "graph-workflow-simple.svg");
outputDot = Files.createTempFile("graph-output", "graph-workflow-simple.svg").toFile();
final String content = IOUtils.getResourceAsString("graph-workflow-simple.xml", -1);
final GraphGenerator g = new GraphGenerator(content, jsonWFJob, true, new GraphvizRenderer());
g.write(new FileOutputStream(outputDot), OutputFormat.SVG);
Expand Down
3 changes: 2 additions & 1 deletion tools/src/main/java/org/apache/oozie/tools/OozieDBCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
Expand Down Expand Up @@ -126,7 +127,7 @@ else if (command.getName().equals(VERSION_CMD)) {
CommandLine commandLine = command.getCommandLine();
String sqlFile = commandLine.getOptionValue(SQL_FILE_OPT);
if (sqlFile == null || sqlFile.isEmpty()) {
File tempFile = File.createTempFile("ooziedb-", ".sql");
File tempFile = Files.createTempFile("ooziedb-", ".sql").toFile();
tempFile.deleteOnExit();
sqlFile = tempFile.getAbsolutePath();
}
Expand Down