解决目录遍历漏洞问题 (#10586)

This commit is contained in:
Isaac 2025-10-09 16:01:00 +08:00 committed by GitHub
parent f977a2488d
commit 39509ad9a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -30,6 +30,10 @@ func setWebStatic(rootRouter *gin.RouterGroup) {
rootRouter.Static("/api/v2/images", path.Join(global.CONF.Base.InstallDir, "1panel/uploads/theme"))
rootRouter.GET("/assets/*filepath", func(c *gin.Context) {
c.Writer.Header().Set("Cache-Control", fmt.Sprintf("private, max-age=%d", 3600))
if c.Request.URL.Path[len(c.Request.URL.Path)-1] == '/' {
c.AbortWithStatus(http.StatusForbidden)
return
}
staticServer := http.FileServer(http.FS(web.Assets))
staticServer.ServeHTTP(c.Writer, c.Request)
})