Skip to content

Commit 496119d

Browse files
yhabteabjulianbrost
authored andcommitted
Validate /dump-* requests method & add some logging
1 parent 2dbd49e commit 496119d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

internal/listener/listener.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ func (l *Listener) checkDebugPassword(w http.ResponseWriter, r *http.Request) bo
168168

169169
_, providedPassword, _ := r.BasicAuth()
170170
if subtle.ConstantTimeCompare([]byte(expectedPassword), []byte(providedPassword)) != 1 {
171+
l.logger.Warnw("Unauthorized request", zap.String("url", r.RequestURI))
172+
171173
w.Header().Set("WWW-Authenticate", `Basic realm="debug"`)
172174
w.WriteHeader(http.StatusUnauthorized)
173175
_, _ = fmt.Fprintln(w, "please provide the debug-password as basic auth credentials (user is ignored)")
@@ -178,6 +180,12 @@ func (l *Listener) checkDebugPassword(w http.ResponseWriter, r *http.Request) bo
178180
}
179181

180182
func (l *Listener) DumpConfig(w http.ResponseWriter, r *http.Request) {
183+
if r.Method != http.MethodGet {
184+
w.WriteHeader(http.StatusMethodNotAllowed)
185+
_, _ = fmt.Fprintln(w, "GET required")
186+
return
187+
}
188+
181189
if !l.checkDebugPassword(w, r) {
182190
return
183191
}
@@ -188,6 +196,12 @@ func (l *Listener) DumpConfig(w http.ResponseWriter, r *http.Request) {
188196
}
189197

190198
func (l *Listener) DumpIncidents(w http.ResponseWriter, r *http.Request) {
199+
if r.Method != http.MethodGet {
200+
w.WriteHeader(http.StatusMethodNotAllowed)
201+
_, _ = fmt.Fprintln(w, "GET required")
202+
return
203+
}
204+
191205
if !l.checkDebugPassword(w, r) {
192206
return
193207
}

0 commit comments

Comments
 (0)