mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-05 07:08:41 +00:00
Only enable debug endpoints if log level is debug or below (#1160)
This commit is contained in:
parent
d5cdd2bb04
commit
d8f598c2ad
1 changed files with 16 additions and 13 deletions
|
@ -16,6 +16,7 @@ package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
|
||||||
"github.com/woodpecker-ci/woodpecker/server/api"
|
"github.com/woodpecker-ci/woodpecker/server/api"
|
||||||
"github.com/woodpecker-ci/woodpecker/server/api/debug"
|
"github.com/woodpecker-ci/woodpecker/server/api/debug"
|
||||||
|
@ -155,6 +156,7 @@ func apiRoutes(e *gin.Engine) {
|
||||||
secrets.DELETE("/:secret", api.DeleteGlobalSecret)
|
secrets.DELETE("/:secret", api.DeleteGlobalSecret)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if zerolog.GlobalLevel() <= zerolog.DebugLevel {
|
||||||
debugger := e.Group("/api/debug")
|
debugger := e.Group("/api/debug")
|
||||||
{
|
{
|
||||||
debugger.Use(session.MustAdmin())
|
debugger.Use(session.MustAdmin())
|
||||||
|
@ -169,6 +171,7 @@ func apiRoutes(e *gin.Engine) {
|
||||||
debugger.POST("/pprof/symbol", debug.SymbolHandler())
|
debugger.POST("/pprof/symbol", debug.SymbolHandler())
|
||||||
debugger.GET("/pprof/trace", debug.TraceHandler())
|
debugger.GET("/pprof/trace", debug.TraceHandler())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logLevel := e.Group("/api/log-level")
|
logLevel := e.Group("/api/log-level")
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue