File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -73,15 +73,21 @@ func DefaultPreRunE(programName string) cobrautil.CobraRunFunc {
73
73
// metrics and pprof endpoints.
74
74
func MetricsHandler (telemetryRegistry * prometheus.Registry ) http.Handler {
75
75
mux := http .NewServeMux ()
76
+
76
77
mux .Handle ("/metrics" , promhttp .Handler ())
78
+ if telemetryRegistry != nil {
79
+ mux .Handle ("/telemetry" , promhttp .HandlerFor (telemetryRegistry , promhttp.HandlerOpts {}))
80
+ }
81
+
77
82
mux .HandleFunc ("/debug/pprof/" , pprof .Index )
78
- mux .HandleFunc ("/debug/pprof/cmdline" , pprof .Cmdline )
79
83
mux .HandleFunc ("/debug/pprof/profile" , pprof .Profile )
80
84
mux .HandleFunc ("/debug/pprof/symbol" , pprof .Symbol )
81
85
mux .HandleFunc ("/debug/pprof/trace" , pprof .Trace )
82
- if telemetryRegistry != nil {
83
- mux .Handle ("/telemetry" , promhttp .HandlerFor (telemetryRegistry , promhttp.HandlerOpts {}))
84
- }
86
+ mux .HandleFunc ("/debug/pprof/cmdline" , func (w http.ResponseWriter , r * http.Request ) {
87
+ w .WriteHeader (http .StatusNotFound )
88
+ fmt .Fprintf (w , "This profile type has been disabled to avoid leaking private command-line arguments" )
89
+ })
90
+
85
91
return mux
86
92
}
87
93
You can’t perform that action at this time.
0 commit comments