Skip to content

Commit

Permalink
Introduced protections against system command injection
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeebot[bot] authored Sep 19, 2024
1 parent 5a4b5fa commit 47e127d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.elasticsearch.gradle.reaper;

import io.github.pixee.security.SystemCommand;
import java.io.Closeable;
import java.io.IOException;
import java.io.UncheckedIOException;
Expand Down Expand Up @@ -68,7 +69,7 @@ private void reap() {
String line = Files.readString(inputFile);
System.out.println("Running command: " + line);
String[] command = line.split(" ");
Process process = Runtime.getRuntime().exec(command);
Process process = SystemCommand.runCommand(Runtime.getRuntime(), command);
int ret = process.waitFor();

System.out.print("Stdout: ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.sun.jna.Pointer;
import com.sun.jna.WString;
import com.sun.jna.ptr.IntByReference;
import io.github.pixee.security.SystemCommand;

import org.apache.lucene.tests.util.LuceneTestCase;
import org.apache.lucene.util.Constants;
Expand Down Expand Up @@ -127,7 +128,7 @@ private static Pointer createPipe(String pipeName, boolean forWrite) throws IOEx
}

private static void createPipeUnix(String pipeName) throws IOException, InterruptedException {
if (Runtime.getRuntime().exec("mkfifo " + pipeName).waitFor() != 0) {
if (SystemCommand.runCommand(Runtime.getRuntime(), "mkfifo " + pipeName).waitFor() != 0) {
throw new IOException("mkfifo failed for pipe " + pipeName);
}
}
Expand Down

0 comments on commit 47e127d

Please sign in to comment.