Only enable debug endpoints if log level is debug or below (#1160)

This commit is contained in:
Anbraten 2022-09-03 20:48:53 +02:00 committed by GitHub
parent d5cdd2bb04
commit d8f598c2ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,7 @@ package router
import (
"github.com/gin-gonic/gin"
"github.com/rs/zerolog"
"github.com/woodpecker-ci/woodpecker/server/api"
"github.com/woodpecker-ci/woodpecker/server/api/debug"
@ -155,6 +156,7 @@ func apiRoutes(e *gin.Engine) {
secrets.DELETE("/:secret", api.DeleteGlobalSecret)
}
if zerolog.GlobalLevel() <= zerolog.DebugLevel {
debugger := e.Group("/api/debug")
{
debugger.Use(session.MustAdmin())
@ -169,6 +171,7 @@ func apiRoutes(e *gin.Engine) {
debugger.POST("/pprof/symbol", debug.SymbolHandler())
debugger.GET("/pprof/trace", debug.TraceHandler())
}
}
logLevel := e.Group("/api/log-level")
{