SWF-706 - ResourceServlet allows HTTP access to sensitive files
This commit is contained in:
@@ -35,7 +35,9 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.PathMatcher;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.HttpServletBean;
|
||||
|
||||
@@ -248,12 +250,14 @@ public class ResourceServlet extends HttpServletBean {
|
||||
if (resourcePath.matches(protectedPath)) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* PathMatcher pathMatcher = new AntPathMatcher(); for (int i = 0; i < allowedResourcePaths.length; i++) {
|
||||
* String pattern = allowedResourcePaths[i]; if (pathMatcher.match(pattern, resourcePath)) { return true; } }
|
||||
* return false;
|
||||
*/
|
||||
return true;
|
||||
PathMatcher pathMatcher = new AntPathMatcher();
|
||||
for (int i = 0; i < allowedResourcePaths.length; i++) {
|
||||
String pattern = allowedResourcePaths[i];
|
||||
if (pathMatcher.match(pattern, resourcePath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,19 +75,6 @@ public class ResourceServletTests extends TestCase {
|
||||
assertEquals(404, response.getStatus());
|
||||
}
|
||||
|
||||
public final void testBenchmark() throws Exception {
|
||||
String requestPath = "/dojo/dojo.js";
|
||||
|
||||
// for (int i = 0; i < 100; i++) {
|
||||
// request = new MockHttpServletRequest();
|
||||
// response = new MockHttpServletResponse();
|
||||
request.setPathInfo(requestPath);
|
||||
servlet.doGet(request, response);
|
||||
|
||||
assertEquals(200, response.getStatus());
|
||||
// }
|
||||
}
|
||||
|
||||
private class ResourceTestMockServletContext extends MockServletContext {
|
||||
|
||||
public String getMimeType(String filePath) {
|
||||
|
||||
Reference in New Issue
Block a user