7
7
import org .springframework .expression .spel .support .SimpleEvaluationContext ;
8
8
import org .springframework .expression .spel .support .StandardEvaluationContext ;
9
9
10
- public class SpelInjection {
10
+ public class SpelInjectionTest {
11
11
12
12
private static final ExpressionParser PARSER = new SpelExpressionParser ();
13
13
@@ -20,7 +20,7 @@ public void testGetValue(Socket socket) throws IOException {
20
20
21
21
ExpressionParser parser = new SpelExpressionParser ();
22
22
Expression expression = parser .parseExpression (input );
23
- expression .getValue ();
23
+ expression .getValue (); // $hasSpelInjection
24
24
}
25
25
26
26
public void testGetValueWithChainedCalls (Socket socket ) throws IOException {
@@ -31,7 +31,7 @@ public void testGetValueWithChainedCalls(Socket socket) throws IOException {
31
31
String input = new String (bytes , 0 , n );
32
32
33
33
Expression expression = new SpelExpressionParser ().parseExpression (input );
34
- expression .getValue ();
34
+ expression .getValue (); // $hasSpelInjection
35
35
}
36
36
37
37
public void testSetValueWithRootObject (Socket socket ) throws IOException {
@@ -45,7 +45,7 @@ public void testSetValueWithRootObject(Socket socket) throws IOException {
45
45
46
46
Object root = new Object ();
47
47
Object value = new Object ();
48
- expression .setValue (root , value );
48
+ expression .setValue (root , value ); // $hasSpelInjection
49
49
}
50
50
51
51
public void testGetValueWithStaticParser (Socket socket ) throws IOException {
@@ -56,7 +56,7 @@ public void testGetValueWithStaticParser(Socket socket) throws IOException {
56
56
String input = new String (bytes , 0 , n );
57
57
58
58
Expression expression = PARSER .parseExpression (input );
59
- expression .getValue ();
59
+ expression .getValue (); // $hasSpelInjection
60
60
}
61
61
62
62
public void testGetValueType (Socket socket ) throws IOException {
@@ -67,7 +67,7 @@ public void testGetValueType(Socket socket) throws IOException {
67
67
String input = new String (bytes , 0 , n );
68
68
69
69
Expression expression = PARSER .parseExpression (input );
70
- expression .getValueType ();
70
+ expression .getValueType (); // $hasSpelInjection
71
71
}
72
72
73
73
public void testWithStandardEvaluationContext (Socket socket ) throws IOException {
@@ -80,7 +80,7 @@ public void testWithStandardEvaluationContext(Socket socket) throws IOException
80
80
Expression expression = PARSER .parseExpression (input );
81
81
82
82
StandardEvaluationContext context = new StandardEvaluationContext ();
83
- expression .getValue (context );
83
+ expression .getValue (context ); // $hasSpelInjection
84
84
}
85
85
86
86
public void testWithSimpleEvaluationContext (Socket socket ) throws IOException {
@@ -93,8 +93,7 @@ public void testWithSimpleEvaluationContext(Socket socket) throws IOException {
93
93
Expression expression = PARSER .parseExpression (input );
94
94
SimpleEvaluationContext context = SimpleEvaluationContext .forReadWriteDataBinding ().build ();
95
95
96
- // the expression is evaluated in a limited context
97
- expression .getValue (context );
96
+ expression .getValue (context ); // Safe - the expression is evaluated in a limited context
98
97
}
99
98
100
99
}
0 commit comments