Skip to content

Commit

Permalink
修复 solon-web-staticfiles 的一个潜在安全问题
Browse files Browse the repository at this point in the history
  • Loading branch information
noear committed Feb 21, 2025
1 parent 8747472 commit f46e47f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
3 changes: 2 additions & 1 deletion UPDATE_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
### v3.0.9
* 修复 solon-docs-openapi2 @Body 注解识别失灵的问题
* 修复 solon-data nested 事务策略单独回滚失效的问题
* 调整 solon-flow 用 layout 替代 nodes 配置(标为弃用)
* 修复 solon-web-staticfiles 的一个潜在安全问题
* 调整 solon-flow 用 layout 替代 nodes 配置(旧的仍可用,标为弃用)

### v3.0.8
* 添加 solon-web-sse SseRender 渲染器,支持 "text/event-stream" 的任意类型处理
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,30 @@ public static void remove(StaticRepository repository) {
public static URL find(String path) throws Exception {
URL rst = null;

for (StaticLocation m : locationMap.values()) {
if (path.startsWith(m.pathPrefix)) {
if (m.repositoryIncPrefix) {
//path = /demo/file.htm
//relativePath = demo/file.htm (没有'/'开头)
rst = m.repository.find(path.substring(1));
} else {
//path = /demo/file.htm
//relativePath = demo/file.htm (没有'/'开头)
if (m.pathPrefixAsFile) {
//如果是文件
int idx = m.pathPrefix.lastIndexOf("/");
rst = m.repository.find(m.pathPrefix.substring(idx + 1));
if (path.contains("/../") == false) {
// '/../' 不安全,禁止进入静态资料库
for (StaticLocation m : locationMap.values()) {
if (path.startsWith(m.pathPrefix)) {
if (m.repositoryIncPrefix) {
//path = /demo/file.htm
//relativePath = demo/file.htm (没有'/'开头)
rst = m.repository.find(path.substring(1));
} else {
//如果是路段
rst = m.repository.find(path.substring(m.pathPrefix.length()));
//path = /demo/file.htm
//relativePath = demo/file.htm (没有'/'开头)
if (m.pathPrefixAsFile) {
//如果是文件
int idx = m.pathPrefix.lastIndexOf("/");
rst = m.repository.find(m.pathPrefix.substring(idx + 1));
} else {
//如果是路段
rst = m.repository.find(path.substring(m.pathPrefix.length()));
}
}
}

if (rst != null) {
return rst;
if (rst != null) {
return rst;
}
}
}
}
Expand Down

0 comments on commit f46e47f

Please sign in to comment.