feat(server): 为静态文件处理添加符号链接安全检查
在 registerStaticHandlersWithLocationEngine 和 registerStaticHandlers 两个方法中设置 SymlinkCheck 安全检查,防止通过符号链接访问敏感文件。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
bbf8032e6a
commit
5f60dc9ff7
@ -1038,6 +1038,9 @@ func (s *Server) registerStaticHandlersWithLocationEngine(cfg *config.ServerConf
|
||||
staticHandler.SetGzipStatic(true, cfg.Compression.GzipStaticExtensions)
|
||||
}
|
||||
|
||||
// 设置符号链接安全检查
|
||||
staticHandler.SetSymlinkCheck(static.SymlinkCheck)
|
||||
|
||||
// 根据 LocationType 注册路由
|
||||
locType := static.LocationType
|
||||
if locType == "" {
|
||||
@ -1383,6 +1386,9 @@ func (s *Server) registerStaticHandlers(router *handler.Router, cfg *config.Serv
|
||||
staticHandler.SetGzipStatic(true, cfg.Compression.GzipStaticExtensions)
|
||||
}
|
||||
|
||||
// 设置符号链接安全检查
|
||||
staticHandler.SetSymlinkCheck(static.SymlinkCheck)
|
||||
|
||||
// 设置 try_files 配置
|
||||
if len(static.TryFiles) > 0 {
|
||||
// 注意:tryFilesPass 需要路由器支持,当前实现传入 nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user