@@ -37,7 +37,7 @@ class InvalidRequestFilterTest {
3737 assertThat " filter.blockBackslash expected to be true" , filter. isBlockBackslash()
3838 assertThat " filter.blockNonAscii expected to be true" , filter. isBlockNonAscii()
3939 assertThat " filter.blockSemicolon expected to be true" , filter. isBlockSemicolon()
40- assertThat " filter.blockTraversal expected to be true " , filter. isBlockTraversal ()
40+ assertThat " filter.blockTraversal expected to be NORMAL " , filter. isBlockTraversalNormal ()
4141 }
4242
4343 @Test
@@ -75,29 +75,63 @@ class InvalidRequestFilterTest {
7575 }
7676
7777 @Test
78- void testBlocksTraversal () {
78+ void testBlocksTraversalNormal () {
7979 InvalidRequestFilter filter = new InvalidRequestFilter ()
8080 assertPathBlocked(filter, " /something/../" )
8181 assertPathBlocked(filter, " /something/../bar" )
8282 assertPathBlocked(filter, " /something/../bar/" )
83- assertPathBlocked(filter, " /something/%2e%2E/bar/" )
8483 assertPathBlocked(filter, " /something/.." )
8584 assertPathBlocked(filter, " /.." )
8685 assertPathBlocked(filter, " .." )
8786 assertPathBlocked(filter, " ../" )
88- assertPathBlocked(filter, " %2E./" )
89- assertPathBlocked(filter, " %2F./" )
9087 assertPathBlocked(filter, " /something/./" )
9188 assertPathBlocked(filter, " /something/./bar" )
9289 assertPathBlocked(filter, " /something/\u 002e/bar" )
9390 assertPathBlocked(filter, " /something/./bar/" )
94- assertPathBlocked(filter, " /something/%2e/bar/" )
95- assertPathBlocked(filter, " /something/%2f/bar/" )
9691 assertPathBlocked(filter, " /something/." )
9792 assertPathBlocked(filter, " /." )
9893 assertPathBlocked(filter, " /something/../something/." )
9994 assertPathBlocked(filter, " /something/../something/." )
95+
96+ assertPathAllowed(filter, " %2E./" )
97+ assertPathAllowed(filter, " %2F./" )
98+ assertPathAllowed(filter, " /something/%2e/bar/" )
99+ assertPathAllowed(filter, " /something/%2f/bar/" )
100+ assertPathAllowed(filter, " /something/http:%2f%2fmydomain.example.com%2foidc/bar/" )
101+ assertPathAllowed(filter, " /something/http:%2f%2fmydomain.example.com%2foidc/bar/" )
102+ assertPathAllowed(filter, " /something/%2e%2E/bar/" )
103+ assertPathAllowed(filter, " /something/http:%2f%2fmydomain%2eexample%2ecom%2foidc/bar/" )
100104 }
105+
106+ @Test
107+ void testBlocksTraversalStrict () {
108+ InvalidRequestFilter filter = new InvalidRequestFilter ()
109+ filter. setPathTraversalBlockMode(InvalidRequestFilter.PathTraversalBlockMode . STRICT )
110+ assertPathBlocked(filter, " /something/../" )
111+ assertPathBlocked(filter, " /something/../bar" )
112+ assertPathBlocked(filter, " /something/../bar/" )
113+ assertPathBlocked(filter, " /something/.." )
114+ assertPathBlocked(filter, " /.." )
115+ assertPathBlocked(filter, " .." )
116+ assertPathBlocked(filter, " ../" )
117+ assertPathBlocked(filter, " /something/./" )
118+ assertPathBlocked(filter, " /something/./bar" )
119+ assertPathBlocked(filter, " /something/\u 002e/bar" )
120+ assertPathBlocked(filter, " /something/./bar/" )
121+ assertPathBlocked(filter, " /something/." )
122+ assertPathBlocked(filter, " /." )
123+ assertPathBlocked(filter, " /something/../something/." )
124+ assertPathBlocked(filter, " /something/../something/." )
125+
126+ assertPathBlocked(filter, " %2E./" )
127+ assertPathBlocked(filter, " %2F./" )
128+ assertPathBlocked(filter, " /something/%2e/bar/" )
129+ assertPathBlocked(filter, " /something/%2f/bar/" )
130+ assertPathBlocked(filter, " /something/http:%2f%2fmydomain.example.com%2foidc/bar/" )
131+ assertPathBlocked(filter, " /something/http:%2f%2fmydomain.example.com%2foidc/bar/" )
132+ assertPathBlocked(filter, " /something/%2e%2E/bar/" )
133+ assertPathBlocked(filter, " /something/http:%2f%2fmydomain%2eexample%2ecom%2foidc/bar/" )
134+ }
101135
102136 @Test
103137 void testFilterAllowsBackslash () {
@@ -149,7 +183,7 @@ class InvalidRequestFilterTest {
149183 @Test
150184 void testAllowTraversal () {
151185 InvalidRequestFilter filter = new InvalidRequestFilter ()
152- filter. setBlockTraversal( false )
186+ filter. setPathTraversalBlockMode( InvalidRequestFilter.PathTraversalBlockMode . NO_BLOCK );
153187
154188 assertPathAllowed(filter, " /something/../" )
155189 assertPathAllowed(filter, " /something/../bar" )
@@ -158,18 +192,23 @@ class InvalidRequestFilterTest {
158192 assertPathAllowed(filter, " /.." )
159193 assertPathAllowed(filter, " .." )
160194 assertPathAllowed(filter, " ../" )
161- assertPathAllowed(filter, " %2E./" )
162- assertPathAllowed(filter, " %2F./" )
163195 assertPathAllowed(filter, " /something/./" )
164196 assertPathAllowed(filter, " /something/./bar" )
165197 assertPathAllowed(filter, " /something/\u 002e/bar" )
166198 assertPathAllowed(filter, " /something\u 002fbar" )
167199 assertPathAllowed(filter, " /something/./bar/" )
168- assertPathAllowed(filter, " /something/%2e/bar/" )
169- assertPathAllowed(filter, " /something/%2f/bar/" )
170200 assertPathAllowed(filter, " /something/." )
171201 assertPathAllowed(filter, " /." )
172202 assertPathAllowed(filter, " /something/../something/." )
203+
204+ assertPathAllowed(filter, " %2E./" )
205+ assertPathAllowed(filter, " %2F./" )
206+ assertPathAllowed(filter, " /something/%2e/bar/" )
207+ assertPathAllowed(filter, " /something/%2f/bar/" )
208+ assertPathAllowed(filter, " /something/http:%2f%2fmydomain.example.com%2foidc/bar/" )
209+ assertPathAllowed(filter, " /something/http:%2f%2fmydomain.example.com%2foidc/bar/" )
210+ assertPathAllowed(filter, " /something/%2e%2E/bar/" )
211+ assertPathAllowed(filter, " /something/http:%2f%2fmydomain%2eexample%2ecom%2foidc/bar/" )
173212 }
174213
175214 static void assertPathBlocked (InvalidRequestFilter filter , String requestUri , String servletPath = requestUri, String pathInfo = null ) {
0 commit comments