File tree Expand file tree Collapse file tree 4 files changed +35
-5
lines changed
main/java/com/hubspot/jinjava/el/ext
test/java/com/hubspot/jinjava Expand file tree Collapse file tree 4 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ String[] allowedDeclaredMethodsFromClasses() {
143143 }
144144 },
145145 JinjavaFilters {
146- private static final String [] ARRAY = { Filter .class .getPackageName () };
146+ private static final String [] ARRAY = { Filter .class .getPackageName () + '.' };
147147
148148 @ Override
149149 String [] allowedDeclaredMethodsFromCanonicalClassPrefixes () {
@@ -169,7 +169,7 @@ String[] allowedReturnTypeClasses() {
169169 }
170170 },
171171 JinjavaExpTests {
172- private static final String [] ARRAY = { ExpTest .class .getPackageName () };
172+ private static final String [] ARRAY = { ExpTest .class .getPackageName () + '.' };
173173
174174 @ Override
175175 String [] allowedDeclaredMethodsFromCanonicalClassPrefixes () {
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ public class BannedAllowlistOptions {
2525
2626 private static final Set <String > ALLOWED_JINJAVA_PREFIXES = Stream
2727 .concat (
28- Stream .of ("com.hubspot.jinjava.testobjects" ),
28+ Stream .of ("com.hubspot.jinjava.testobjects. " ),
2929 Arrays
3030 .stream (AllowlistGroup .values ())
3131 .flatMap (g ->
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ public abstract class BaseJinjavaTest {
1414 .builder ()
1515 .addDefaultAllowlistGroups ()
1616 .addAllowedDeclaredMethodsFromCanonicalClassPrefixes (
17- "com.hubspot.jinjava.testobjects"
17+ "com.hubspot.jinjava.testobjects. "
1818 )
1919 .build ()
2020 );
@@ -23,7 +23,7 @@ public abstract class BaseJinjavaTest {
2323 ReturnTypeValidatorConfig
2424 .builder ()
2525 .addDefaultAllowlistGroups ()
26- .addAllowedCanonicalClassPrefixes ("com.hubspot.jinjava.testobjects" )
26+ .addAllowedCanonicalClassPrefixes ("com.hubspot.jinjava.testobjects. " )
2727 .build ()
2828 );
2929 public Jinjava jinjava ;
Original file line number Diff line number Diff line change 44
55import com .fasterxml .jackson .databind .ObjectMapper ;
66import com .hubspot .jinjava .interpret .JinjavaInterpreter ;
7+ import com .hubspot .jinjava .lib .exptest .ExpTest ;
8+ import com .hubspot .jinjava .lib .filter .Filter ;
79import java .lang .reflect .Method ;
810import org .junit .Test ;
911
@@ -119,6 +121,34 @@ public void itRejectsJacksonDatabindPackageInAllowedDeclaredMethodPrefixes() {
119121 .hasMessageContaining ("Banned classes or prefixes" );
120122 }
121123
124+ @ Test
125+ public void itRejectsEvilJinjavaFilterPathInAllowedDeclaredMethodPrefixes () {
126+ assertThatThrownBy (() ->
127+ MethodValidatorConfig
128+ .builder ()
129+ .addAllowedDeclaredMethodsFromCanonicalClassPrefixes (
130+ Filter .class .getPackageName () + "_evil"
131+ )
132+ .build ()
133+ )
134+ .isInstanceOf (IllegalStateException .class )
135+ .hasMessageContaining ("Banned classes or prefixes" );
136+ }
137+
138+ @ Test
139+ public void itRejectsEvilJinjavaExptestPathInAllowedDeclaredMethodPrefixes () {
140+ assertThatThrownBy (() ->
141+ MethodValidatorConfig
142+ .builder ()
143+ .addAllowedDeclaredMethodsFromCanonicalClassPrefixes (
144+ ExpTest .class .getPackageName () + "_evil"
145+ )
146+ .build ()
147+ )
148+ .isInstanceOf (IllegalStateException .class )
149+ .hasMessageContaining ("Banned classes or prefixes" );
150+ }
151+
122152 // ReturnTypeValidatorConfig: allowedCanonicalClassNames() path
123153
124154 @ Test
You can’t perform that action at this time.
0 commit comments