SanitizedDefaultServeMux returns an http.Handler that wraps http.DefaultServeMux but blocks endpoints that expose the full process command line (which may include the admin token from --security "token=..."): - /debug/pprof/cmdline — registered by net/http/pprof - /debug/vars — served with
()
| 121 | // - /debug/pprof/cmdline — registered by net/http/pprof |
| 122 | // - /debug/vars — served with a filtered handler that omits "cmdline" |
| 123 | func SanitizedDefaultServeMux() http.Handler { |
| 124 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 125 | if r.URL.Path == "/debug/pprof/cmdline" { |
| 126 | http.NotFound(w, r) |
| 127 | return |
| 128 | } |
| 129 | if r.URL.Path == "/debug/vars" { |
| 130 | filteredExpvarHandler(w, r) |
| 131 | return |
| 132 | } |
| 133 | http.DefaultServeMux.ServeHTTP(w, r) |
| 134 | }) |
| 135 | } |
no test coverage detected