Skip to content

Commit d73905c

Browse files
authored
add CommandInjection.java
1 parent e4b02cd commit d73905c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// https://documentation.blackduck.com/bundle/coverity-docs/page/checker-ref/checkers/NO/os_cmd_injection.html
2+
3+
import java.io.*;
4+
import javax.servlet.http.HttpServletRequest;
5+
6+
public class CommandInjection {
7+
public static Process runCmd(HttpServletRequest request) throws IOException {
8+
String filename = request.getParameter("filename");
9+
ProcessBuilder builder = new ProcessBuilder("cat", filename);
10+
Process process = builder.start();
11+
return(process);
12+
}
13+
}

0 commit comments

Comments
 (0)