forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...http/deployment/src/test/java/io/quarkus/vertx/http/proxy/DotDotSemicolonSegmentTest.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,40 @@ | ||
package io.quarkus.vertx.http.proxy; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
/** | ||
* Make sure that `/..;/` appended to a path is not resolved to `/`, as this | ||
* would allow to escape the allowed context when passing through proxies | ||
* (httpd does not recognize it as a double-dot segment and lets the request | ||
* through without sanitizing the path). | ||
*/ | ||
public class DotDotSemicolonSegmentTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest().withApplicationRoot(jar -> { | ||
jar.addAsResource(new StringAsset("Hello"), "META-INF/resources/index.html"); | ||
}); | ||
|
||
@Test | ||
public void testPathIsNotResolved() { | ||
given() | ||
.get("/index.html") | ||
.then() | ||
.statusCode(200); | ||
given() | ||
.get("/something/../index.html") | ||
.then() | ||
.statusCode(200); | ||
given() | ||
.get("/something/..;/index.html") | ||
.then() | ||
.statusCode(404); | ||
} | ||
|
||
} |