Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public Response createResponse(ResolverMap rr, String resPath) {
} catch (Exception e) {
return internal(router.getConfiguration().isProduction(), getDisplayName())
.title("Could not resolve file")
.topLevel("path", resPath)
.internal("path", resPath)
.exception(e)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,26 @@ void generateIndex() {
assertTrue(body.contains("<a href=\"./index.html\">index.html</a>"));
assertTrue(body.contains("<a href=\"./page.html\">page.html</a>"));
}

@Test
void createResponseHidesPathInProduction() throws Exception {
Router prod = DummyTestRouter.productionRouter();
WebServerInterceptor prodWs = new WebServerInterceptor(prod);

JsonNode body = om.readTree(prodWs.createResponse(prod.getResolverMap(), "file:/installation/product/client/nonexisting")
.getBodyAsStringDecoded());

// The absolute installation path must not leak to the client in production mode.
assertFalse(body.has("path"));
assertFalse(body.toString().contains("installation/product/client"));
}

@Test
void createResponseExposesPathInDevelopment() throws Exception {
JsonNode body = om.readTree(ws.createResponse(r.getResolverMap(), "file:/installation/product/client/nonexisting")
.getBodyAsStringDecoded());

// In development mode the path stays available to aid debugging.
assertEquals("file:/installation/product/client/nonexisting", body.get("path").asText());
}
}
Loading