From de94c5eb492bfa5ace4cf1bb1ae3e0747350d9ce Mon Sep 17 00:00:00 2001 From: Seednode Date: Sun, 7 Jan 2024 22:25:00 -0600 Subject: [PATCH] Redact admin prefix when registering profiling handlers, too --- cmd/profile.go | 5 +++++ cmd/root.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/profile.go b/cmd/profile.go index 90bec5c..de7a8ee 100644 --- a/cmd/profile.go +++ b/cmd/profile.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" "net/http/pprof" + "strings" "time" "github.com/julienschmidt/httprouter" @@ -16,6 +17,10 @@ import ( func registerProfileHandler(mux *httprouter.Router, verb, path string, handler http.HandlerFunc) { mux.HandlerFunc(verb, path, handler) + if Redact && AdminPrefix != "" { + path = strings.ReplaceAll(path, AdminPrefix, "/") + } + if Handlers { fmt.Printf("%s | SERVE: Registered handler for %s\n", time.Now().Format(logDate), diff --git a/cmd/root.go b/cmd/root.go index c38f426..3fab6aa 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,7 +17,7 @@ import ( const ( AllowedCharacters string = `^[A-z0-9.\-_]+$` - ReleaseVersion string = "4.0.1" + ReleaseVersion string = "4.0.2" ) var (