Skip to content

Commit

Permalink
Bug fix#3 command injection
Browse files Browse the repository at this point in the history
  • Loading branch information
hhimani committed Nov 13, 2018
1 parent 92f8c85 commit 98afb44
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions api/src/test/java/org/openmrs/test/MigrateDataSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,14 @@ private static String execMysqlCmd(String cmd, String sourceFile, boolean includ
// file system permission issue.
// Could not create lcab.tmp file in default working directory
// (jmiranda).
Process p = (wd != null) ? Runtime.getRuntime().exec(cmds, null, wd) : Runtime.getRuntime().exec(cmds);

if(Process p = (wd != null)){
final List<String> blkList = Arrays.asList("command1","command2","command3");
final List<String> whiList = Arrays.asList("command11","command22","command33");
if(whilist.contains(cmds))
Runtime.getRuntime().exec(cmds,null,wd);
else if(blkList.contains(cmds))
Runtime.getRuntime().exec(cmds);
}
// get the stdout
out.append("Normal cmd output:\n");
Reader reader = new InputStreamReader(p.getInputStream());
Expand Down

0 comments on commit 98afb44

Please sign in to comment.