|
1 |
| -import groovy.lang.GroovyCodeSource; |
2 |
| -import groovy.lang.GroovyShell; |
3 |
| - |
| 1 | +import java.io.IOException; |
| 2 | +import java.io.Reader; |
| 3 | +import java.io.StringReader; |
| 4 | +import java.net.URI; |
| 5 | +import java.net.URISyntaxException; |
| 6 | +import java.util.ArrayList; |
4 | 7 | import javax.servlet.ServletException;
|
5 | 8 | import javax.servlet.http.HttpServlet;
|
6 | 9 | import javax.servlet.http.HttpServletRequest;
|
7 | 10 | import javax.servlet.http.HttpServletResponse;
|
8 |
| -import java.io.IOException; |
| 11 | +import groovy.lang.GroovyCodeSource; |
| 12 | +import groovy.lang.GroovyShell; |
9 | 13 |
|
10 | 14 | public class GroovyShellTest extends HttpServlet {
|
11 | 15 |
|
12 | 16 | protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
13 | 17 | throws ServletException, IOException {
|
14 |
| - GroovyShell shell = new GroovyShell(); |
15 |
| - String script = request.getParameter("script"); |
16 |
| - shell.evaluate(script); // $hasGroovyInjection |
17 |
| - } |
18 |
| - |
19 |
| - protected void doPost(HttpServletRequest request, HttpServletResponse response) |
20 |
| - throws ServletException, IOException { |
21 |
| - GroovyShell shell = new GroovyShell(); |
22 |
| - String script = request.getParameter("script"); |
23 |
| - shell.evaluate(script, "test"); // $hasGroovyInjection |
24 |
| - } |
25 |
| - |
26 |
| - protected void doPut(HttpServletRequest request, HttpServletResponse response) |
27 |
| - throws ServletException, IOException { |
28 |
| - GroovyShell shell = new GroovyShell(); |
29 |
| - String script = request.getParameter("script"); |
30 |
| - shell.evaluate(script, "test", "test2"); // $hasGroovyInjection |
31 |
| - } |
32 |
| - |
33 |
| - protected void doOptions(HttpServletRequest request, HttpServletResponse response) |
34 |
| - throws ServletException, IOException { |
35 |
| - GroovyShell shell = new GroovyShell(); |
36 |
| - String script = request.getParameter("script"); |
37 |
| - shell.run(script, "_", new String[] {}); // $hasGroovyInjection |
38 |
| - } |
39 |
| - |
40 |
| - protected void doHead(HttpServletRequest request, HttpServletResponse response) |
41 |
| - throws ServletException, IOException { |
42 |
| - GroovyShell shell = new GroovyShell(); |
43 |
| - String script = request.getParameter("script"); |
44 |
| - GroovyCodeSource gcs = new GroovyCodeSource(script, "test", "Test"); |
45 |
| - shell.run(gcs, new String[] {}); // $hasGroovyInjection |
46 |
| - } |
47 |
| - |
48 |
| - protected void doDelete(HttpServletRequest request, HttpServletResponse response) |
49 |
| - throws ServletException, IOException { |
50 |
| - GroovyShell shell = new GroovyShell(); |
51 |
| - String script = request.getParameter("script"); |
52 |
| - GroovyCodeSource gcs = new GroovyCodeSource(script, "test", "Test"); |
53 |
| - shell.evaluate(gcs); // $hasGroovyInjection |
54 |
| - } |
55 | 18 |
|
56 |
| - protected void doPatch(HttpServletRequest request, HttpServletResponse response) |
57 |
| - throws ServletException, IOException { |
58 |
| - GroovyShell shell = new GroovyShell(); |
59 |
| - String script = request.getParameter("script"); |
60 |
| - shell.parse(script); // $hasGroovyInjection |
| 19 | + // "groovy.lang;GroovyShell;false;evaluate;(GroovyCodeSource);;Argument[0];groovy", |
| 20 | + { |
| 21 | + GroovyShell shell = new GroovyShell(); |
| 22 | + String script = request.getParameter("script"); |
| 23 | + GroovyCodeSource gcs = new GroovyCodeSource(script, "test", "Test"); |
| 24 | + shell.evaluate(gcs); // $hasGroovyInjection |
| 25 | + } |
| 26 | + // "groovy.lang;GroovyShell;false;evaluate;(Reader);;Argument[0];groovy", |
| 27 | + { |
| 28 | + GroovyShell shell = new GroovyShell(); |
| 29 | + String script = request.getParameter("script"); |
| 30 | + Reader reader = new StringReader(script); |
| 31 | + shell.evaluate(reader); // $hasGroovyInjection |
| 32 | + } |
| 33 | + // "groovy.lang;GroovyShell;false;evaluate;(Reader,String);;Argument[0];groovy", |
| 34 | + { |
| 35 | + GroovyShell shell = new GroovyShell(); |
| 36 | + String script = request.getParameter("script"); |
| 37 | + Reader reader = new StringReader(script); |
| 38 | + shell.evaluate(reader, "_"); // $hasGroovyInjection |
| 39 | + } |
| 40 | + // "groovy.lang;GroovyShell;false;evaluate;(String);;Argument[0];groovy", |
| 41 | + { |
| 42 | + GroovyShell shell = new GroovyShell(); |
| 43 | + String script = request.getParameter("script"); |
| 44 | + shell.evaluate(script); // $hasGroovyInjection |
| 45 | + } |
| 46 | + // "groovy.lang;GroovyShell;false;evaluate;(String,String);;Argument[0];groovy", |
| 47 | + { |
| 48 | + GroovyShell shell = new GroovyShell(); |
| 49 | + String script = request.getParameter("script"); |
| 50 | + shell.evaluate(script, "test"); // $hasGroovyInjection |
| 51 | + } |
| 52 | + // "groovy.lang;GroovyShell;false;evaluate;(String,String,String);;Argument[0];groovy", |
| 53 | + { |
| 54 | + GroovyShell shell = new GroovyShell(); |
| 55 | + String script = request.getParameter("script"); |
| 56 | + shell.evaluate(script, "test", "test2"); // $hasGroovyInjection |
| 57 | + } |
| 58 | + // "groovy.lang;GroovyShell;false;evaluate;(URI);;Argument[0];groovy", |
| 59 | + try { |
| 60 | + GroovyShell shell = new GroovyShell(); |
| 61 | + String script = request.getParameter("script"); |
| 62 | + shell.parse(new URI(script)); // $hasGroovyInjection |
| 63 | + } catch (URISyntaxException e) { |
| 64 | + } |
| 65 | + // "groovy.lang;GroovyShell;false;parse;(Reader);;Argument[0];groovy", |
| 66 | + { |
| 67 | + GroovyShell shell = new GroovyShell(); |
| 68 | + String script = request.getParameter("script"); |
| 69 | + Reader reader = new StringReader(script); |
| 70 | + shell.parse(reader); // $hasGroovyInjection |
| 71 | + } |
| 72 | + // "groovy.lang;GroovyShell;false;parse;(Reader,String);;Argument[0];groovy", |
| 73 | + { |
| 74 | + GroovyShell shell = new GroovyShell(); |
| 75 | + String script = request.getParameter("script"); |
| 76 | + Reader reader = new StringReader(script); |
| 77 | + shell.parse(reader, "_"); // $hasGroovyInjection |
| 78 | + } |
| 79 | + // "groovy.lang;GroovyShell;false;parse;(String);;Argument[0];groovy", |
| 80 | + { |
| 81 | + GroovyShell shell = new GroovyShell(); |
| 82 | + String script = request.getParameter("script"); |
| 83 | + shell.parse(script); // $hasGroovyInjection |
| 84 | + } |
| 85 | + // "groovy.lang;GroovyShell;false;parse;(String,String);;Argument[0];groovy", |
| 86 | + { |
| 87 | + GroovyShell shell = new GroovyShell(); |
| 88 | + String script = request.getParameter("script"); |
| 89 | + shell.parse(script, "_"); // $hasGroovyInjection |
| 90 | + } |
| 91 | + // "groovy.lang;GroovyShell;false;parse;(URI);;Argument[0];groovy", |
| 92 | + try { |
| 93 | + GroovyShell shell = new GroovyShell(); |
| 94 | + String script = request.getParameter("script"); |
| 95 | + shell.parse(new URI(script)); // $hasGroovyInjection |
| 96 | + } catch (URISyntaxException e) { |
| 97 | + } |
| 98 | + // "groovy.lang;GroovyShell;false;run;(GroovyCodeSource,String[]);;Argument[0];groovy", |
| 99 | + { |
| 100 | + GroovyShell shell = new GroovyShell(); |
| 101 | + String script = request.getParameter("script"); |
| 102 | + GroovyCodeSource gcs = new GroovyCodeSource(script, "test", "Test"); |
| 103 | + shell.run(gcs, new String[] {}); // $hasGroovyInjection |
| 104 | + } |
| 105 | + // "groovy.lang;GroovyShell;false;run;(GroovyCodeSource,List);;Argument[0];groovy", |
| 106 | + { |
| 107 | + GroovyShell shell = new GroovyShell(); |
| 108 | + String script = request.getParameter("script"); |
| 109 | + GroovyCodeSource gcs = new GroovyCodeSource(script, "test", "Test"); |
| 110 | + shell.run(gcs, new ArrayList<String>()); // $hasGroovyInjection |
| 111 | + } |
| 112 | + // "groovy.lang;GroovyShell;false;run;(Reader,String,String[]);;Argument[0];groovy", |
| 113 | + { |
| 114 | + GroovyShell shell = new GroovyShell(); |
| 115 | + String script = request.getParameter("script"); |
| 116 | + Reader reader = new StringReader(script); |
| 117 | + shell.run(reader, "test", new String[] {}); // $hasGroovyInjection |
| 118 | + } |
| 119 | + // "groovy.lang;GroovyShell;false;run;(Reader,String,List);;Argument[0];groovy", |
| 120 | + { |
| 121 | + GroovyShell shell = new GroovyShell(); |
| 122 | + String script = request.getParameter("script"); |
| 123 | + Reader reader = new StringReader(script); |
| 124 | + shell.run(reader, "test", new ArrayList<String>()); // $hasGroovyInjection |
| 125 | + } |
| 126 | + // "groovy.lang;GroovyShell;false;run;(String,String,String[]);;Argument[0];groovy", |
| 127 | + { |
| 128 | + GroovyShell shell = new GroovyShell(); |
| 129 | + String script = request.getParameter("script"); |
| 130 | + shell.run(script, "_", new String[] {}); // $hasGroovyInjection |
| 131 | + } |
| 132 | + // "groovy.lang;GroovyShell;false;run;(String,String,List);;Argument[0];groovy", |
| 133 | + { |
| 134 | + GroovyShell shell = new GroovyShell(); |
| 135 | + String script = request.getParameter("script"); |
| 136 | + shell.run(script, "_", new ArrayList<String>()); // $hasGroovyInjection |
| 137 | + } |
| 138 | + // "groovy.lang;GroovyShell;false;run;(URI,String[]);;Argument[0];groovy", |
| 139 | + try { |
| 140 | + GroovyShell shell = new GroovyShell(); |
| 141 | + String script = request.getParameter("script"); |
| 142 | + shell.run(new URI(script), new String[] {}); // $hasGroovyInjection |
| 143 | + } catch (URISyntaxException e) { |
| 144 | + } |
| 145 | + // "groovy.lang;GroovyShell;false;run;(URI,List);;Argument[0];groovy", |
| 146 | + try { |
| 147 | + GroovyShell shell = new GroovyShell(); |
| 148 | + String script = request.getParameter("script"); |
| 149 | + shell.run(new URI(script), new ArrayList<String>()); // $hasGroovyInjection |
| 150 | + } catch (URISyntaxException e) { |
| 151 | + } |
61 | 152 | }
|
62 | 153 | }
|
63 | 154 |
|
0 commit comments