-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the webroot escape to classpath on windows
Signed-off-by: Paulo Lopes <pmlopes@gmail.com>
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
vertx-web/src/test/java/io/vertx/ext/web/handler/StaticHandlerWindowsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * Copyright 2014 Red Hat, Inc. | ||
| * | ||
| * All rights reserved. This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License v1.0 | ||
| * and Apache License v2.0 which accompanies this distribution. | ||
| * | ||
| * The Eclipse Public License is available at | ||
| * http://www.eclipse.org/legal/epl-v10.html | ||
| * | ||
| * The Apache License v2.0 is available at | ||
| * http://www.opensource.org/licenses/apache2.0.php | ||
| * | ||
| * You may elect to redistribute this code under either of these licenses. | ||
| */ | ||
|
|
||
| package io.vertx.ext.web.handler; | ||
|
|
||
| import io.vertx.core.http.HttpMethod; | ||
| import io.vertx.ext.web.WebTestBase; | ||
| import org.junit.Test; | ||
|
|
||
| public class StaticHandlerWindowsTest extends WebTestBase { | ||
|
|
||
| @Test | ||
| public void testEscapeToClasspathFromWildcard() throws Exception { | ||
| router.clear(); | ||
| router.route("/*").handler(StaticHandler.create("www")); | ||
| // attempt to escape to classpath, given that the handler is mounted on a wildcard, | ||
| // reading the wildcard must return a sanitized path and therefore not allow to escape. | ||
| testRequest(HttpMethod.GET, "/..\\.htdigest", 404, "Not Found"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testEscapeToClasspathFromNull() throws Exception { | ||
| router.clear(); | ||
| router.route().handler(StaticHandler.create("www")); | ||
| // attempt to escape to classpath, given that the handler is mounted on a catch all path | ||
| testRequest(HttpMethod.GET, "/..\\.htdigest", 404, "Not Found"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testEscapeToClasspathFromRegEx() throws Exception { | ||
| router.clear(); | ||
| router.routeWithRegex(".*").handler(StaticHandler.create("www")); | ||
| // attempt to escape to classpath, given that the handler is mounted on a regex, | ||
| testRequest(HttpMethod.GET, "/..\\.htdigest", 404, "Not Found"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testEscapeToClasspathFromFixedPath() throws Exception { | ||
| router.clear(); | ||
| router.routeWithRegex("/").handler(StaticHandler.create("www")); | ||
| // attempt to escape to classpath, given that the handler is mounted on a regex, | ||
| testRequest(HttpMethod.GET, "/..\\.htdigest", 404, "Not Found"); | ||
| } | ||
| } |