|
19 | 19 | import org.mvel2.templates.TemplateCompiler;
|
20 | 20 | import org.mvel2.templates.TemplateRuntime;
|
21 | 21 |
|
22 |
| -public class MvelInjection { |
| 22 | +public class MvelInjectionTest { |
23 | 23 |
|
24 | 24 | public static void testWithMvelEval(Socket socket) throws IOException {
|
25 |
| - MVEL.eval(read(socket)); |
| 25 | + MVEL.eval(read(socket)); // $hasMvelInjection |
26 | 26 | }
|
27 | 27 |
|
28 | 28 | public static void testWithMvelCompileAndExecute(Socket socket) throws IOException {
|
29 | 29 | Serializable expression = MVEL.compileExpression(read(socket));
|
30 |
| - MVEL.executeExpression(expression); |
| 30 | + MVEL.executeExpression(expression); // $hasMvelInjection |
31 | 31 | }
|
32 | 32 |
|
33 | 33 | public static void testWithExpressionCompiler(Socket socket) throws IOException {
|
34 | 34 | ExpressionCompiler compiler = new ExpressionCompiler(read(socket));
|
35 | 35 | ExecutableStatement statement = compiler.compile();
|
36 |
| - statement.getValue(new Object(), new ImmutableDefaultFactory()); |
37 |
| - statement.getValue(new Object(), new Object(), new ImmutableDefaultFactory()); |
| 36 | + statement.getValue(new Object(), new ImmutableDefaultFactory()); // $hasMvelInjection |
| 37 | + statement.getValue(new Object(), new Object(), new ImmutableDefaultFactory()); // $hasMvelInjection |
38 | 38 | }
|
39 | 39 |
|
40 | 40 | public static void testWithCompiledExpressionGetDirectValue(Socket socket) throws IOException {
|
41 | 41 | ExpressionCompiler compiler = new ExpressionCompiler(read(socket));
|
42 | 42 | CompiledExpression expression = compiler.compile();
|
43 |
| - expression.getDirectValue(new Object(), new ImmutableDefaultFactory()); |
| 43 | + expression.getDirectValue(new Object(), new ImmutableDefaultFactory()); // $hasMvelInjection |
44 | 44 | }
|
45 | 45 |
|
46 | 46 | public static void testCompiledAccExpressionGetValue(Socket socket) throws IOException {
|
47 |
| - CompiledAccExpression expression = new CompiledAccExpression( |
48 |
| - read(socket).toCharArray(), Object.class, new ParserContext()); |
49 |
| - expression.getValue(new Object(), new ImmutableDefaultFactory()); |
| 47 | + CompiledAccExpression expression = |
| 48 | + new CompiledAccExpression(read(socket).toCharArray(), Object.class, new ParserContext()); |
| 49 | + expression.getValue(new Object(), new ImmutableDefaultFactory()); // $hasMvelInjection |
50 | 50 | }
|
51 | 51 |
|
52 | 52 | public static void testMvelScriptEngineCompileAndEvaluate(Socket socket) throws Exception {
|
53 | 53 | String input = read(socket);
|
54 | 54 |
|
55 | 55 | MvelScriptEngine engine = new MvelScriptEngine();
|
56 | 56 | CompiledScript compiledScript = engine.compile(input);
|
57 |
| - compiledScript.eval(); |
| 57 | + compiledScript.eval(); // $hasMvelInjection |
58 | 58 |
|
59 | 59 | Serializable script = engine.compiledScript(input);
|
60 |
| - engine.evaluate(script, new SimpleScriptContext()); |
| 60 | + engine.evaluate(script, new SimpleScriptContext()); // $hasMvelInjection |
61 | 61 | }
|
62 | 62 |
|
63 | 63 | public static void testMvelCompiledScriptCompileAndEvaluate(Socket socket) throws Exception {
|
64 | 64 | MvelScriptEngine engine = new MvelScriptEngine();
|
65 | 65 | ExpressionCompiler compiler = new ExpressionCompiler(read(socket));
|
66 | 66 | ExecutableStatement statement = compiler.compile();
|
67 | 67 | MvelCompiledScript script = new MvelCompiledScript(engine, statement);
|
68 |
| - script.eval(new SimpleScriptContext()); |
| 68 | + script.eval(new SimpleScriptContext()); // $hasMvelInjection |
69 | 69 | }
|
70 | 70 |
|
71 | 71 | public static void testTemplateRuntimeEval(Socket socket) throws Exception {
|
72 |
| - TemplateRuntime.eval(read(socket), new HashMap()); |
| 72 | + TemplateRuntime.eval(read(socket), new HashMap()); // $hasMvelInjection |
73 | 73 | }
|
74 | 74 |
|
75 | 75 | public static void testTemplateRuntimeCompileTemplateAndExecute(Socket socket) throws Exception {
|
76 |
| - TemplateRuntime.execute( |
77 |
| - TemplateCompiler.compileTemplate(read(socket)), new HashMap()); |
| 76 | + TemplateRuntime.execute(TemplateCompiler.compileTemplate(read(socket)), new HashMap()); // $hasMvelInjection |
78 | 77 | }
|
79 | 78 |
|
80 | 79 | public static void testTemplateRuntimeCompileAndExecute(Socket socket) throws Exception {
|
81 | 80 | TemplateCompiler compiler = new TemplateCompiler(read(socket));
|
82 |
| - TemplateRuntime.execute(compiler.compile(), new HashMap()); |
| 81 | + TemplateRuntime.execute(compiler.compile(), new HashMap()); // $hasMvelInjection |
83 | 82 | }
|
84 | 83 |
|
85 | 84 | public static void testMvelRuntimeExecute(Socket socket) throws Exception {
|
86 | 85 | ExpressionCompiler compiler = new ExpressionCompiler(read(socket));
|
87 | 86 | CompiledExpression expression = compiler.compile();
|
88 |
| - MVELRuntime.execute(false, expression, new Object(), new ImmutableDefaultFactory()); |
| 87 | + MVELRuntime.execute(false, expression, new Object(), new ImmutableDefaultFactory()); // $hasMvelInjection |
89 | 88 | }
|
90 | 89 |
|
91 | 90 | public static String read(Socket socket) throws IOException {
|
|
0 commit comments