77import org .springframework .expression .spel .support .SimpleEvaluationContext ;
88import org .springframework .expression .spel .support .StandardEvaluationContext ;
99
10- public class SpelInjection {
10+ public class SpelInjectionTest {
1111
1212 private static final ExpressionParser PARSER = new SpelExpressionParser ();
1313
@@ -20,7 +20,7 @@ public void testGetValue(Socket socket) throws IOException {
2020
2121 ExpressionParser parser = new SpelExpressionParser ();
2222 Expression expression = parser .parseExpression (input );
23- expression .getValue ();
23+ expression .getValue (); // $hasSpelInjection
2424 }
2525
2626 public void testGetValueWithChainedCalls (Socket socket ) throws IOException {
@@ -31,7 +31,7 @@ public void testGetValueWithChainedCalls(Socket socket) throws IOException {
3131 String input = new String (bytes , 0 , n );
3232
3333 Expression expression = new SpelExpressionParser ().parseExpression (input );
34- expression .getValue ();
34+ expression .getValue (); // $hasSpelInjection
3535 }
3636
3737 public void testSetValueWithRootObject (Socket socket ) throws IOException {
@@ -45,7 +45,7 @@ public void testSetValueWithRootObject(Socket socket) throws IOException {
4545
4646 Object root = new Object ();
4747 Object value = new Object ();
48- expression .setValue (root , value );
48+ expression .setValue (root , value ); // $hasSpelInjection
4949 }
5050
5151 public void testGetValueWithStaticParser (Socket socket ) throws IOException {
@@ -56,7 +56,7 @@ public void testGetValueWithStaticParser(Socket socket) throws IOException {
5656 String input = new String (bytes , 0 , n );
5757
5858 Expression expression = PARSER .parseExpression (input );
59- expression .getValue ();
59+ expression .getValue (); // $hasSpelInjection
6060 }
6161
6262 public void testGetValueType (Socket socket ) throws IOException {
@@ -67,7 +67,7 @@ public void testGetValueType(Socket socket) throws IOException {
6767 String input = new String (bytes , 0 , n );
6868
6969 Expression expression = PARSER .parseExpression (input );
70- expression .getValueType ();
70+ expression .getValueType (); // $hasSpelInjection
7171 }
7272
7373 public void testWithStandardEvaluationContext (Socket socket ) throws IOException {
@@ -80,7 +80,7 @@ public void testWithStandardEvaluationContext(Socket socket) throws IOException
8080 Expression expression = PARSER .parseExpression (input );
8181
8282 StandardEvaluationContext context = new StandardEvaluationContext ();
83- expression .getValue (context );
83+ expression .getValue (context ); // $hasSpelInjection
8484 }
8585
8686 public void testWithSimpleEvaluationContext (Socket socket ) throws IOException {
@@ -93,8 +93,7 @@ public void testWithSimpleEvaluationContext(Socket socket) throws IOException {
9393 Expression expression = PARSER .parseExpression (input );
9494 SimpleEvaluationContext context = SimpleEvaluationContext .forReadWriteDataBinding ().build ();
9595
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
9897 }
9998
10099}
0 commit comments