forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
73 lines (62 loc) · 1.92 KB
/
Test.java
File metadata and controls
73 lines (62 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import java.io.IOException;
import java.util.ArrayList;
import org.apache.commons.exec.*;
class Test {
void pbuilderConstructor2() {
new ProcessBuilder("cmd", "arg1", "arg2");
}
void pbuilderConstructorList() {
ArrayList args = new ArrayList();
args.add("cmd");
args.add("arg1");
new ProcessBuilder(args);
}
void pbuilderSetter() {
ProcessBuilder pbuilder = new ProcessBuilder();
pbuilder.command("cmd", "arg1", "arg2");
}
void pbuilderSetterList() {
ArrayList args = new ArrayList();
args.add("cmd");
args.add("arg1");
ProcessBuilder pbuilder = new ProcessBuilder();
pbuilder.command(args);
}
void runtimeExec() throws IOException {
Runtime.getRuntime().exec("cmd arg1 arg2");
}
void runtimeExecArray() throws IOException {
Runtime.getRuntime().exec(new String[] { "cmd", "arg1", "arg2" });
}
void execOnOtherClass() {
class Bogus {
void exec(String command) {
}
}
new Bogus().exec("Irrelevant version of exec");
}
void apacheExecute1() throws IOException {
String line = "AcroRd32.exe /p /h some.file";
CommandLine cmdLine = CommandLine.parse(line);
DefaultExecutor executor = new DefaultExecutor();
int exitValue = executor.execute(cmdLine);
}
void apacheExecute2() throws IOException {
String line = "AcroRd32.exe /p /h some.file";
CommandLine cmdLine = CommandLine.parse(line, null);
DefaultExecutor executor = new DefaultExecutor();
int exitValue = executor.execute(cmdLine);
}
void apacheExecute3() throws IOException {
CommandLine cmdLine = new CommandLine("AcroRd32.exe");
cmdLine.addArguments("/p /h some.file");
DefaultExecutor executor = new DefaultExecutor();
int exitValue = executor.execute(cmdLine);
}
void apacheExecute4() throws IOException {
CommandLine cmdLine = new CommandLine("AcroRd32.exe");
cmdLine.addArguments("/p /h some.file", false);
DefaultExecutor executor = new DefaultExecutor();
int exitValue = executor.execute(cmdLine);
}
}