Skip to content

Commit

Permalink
Merge branch 'main' into renovate/tj-actions-changed-files-digest
Browse files Browse the repository at this point in the history
  • Loading branch information
hisarbalik authored Feb 20, 2025
2 parents dc8f54c + 38140ea commit adeb58c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/selfmonitor/webhook/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

alertsYAML, err := io.ReadAll(r.Body)
const maxBytesToRead = 1 << 20 // 1 MB

alertsYAML, err := io.ReadAll(http.MaxBytesReader(w, r.Body, maxBytesToRead)) // Limit max bytes read (avoid "prone to resource exhaustion" security warning)
if err != nil {
h.logger.Error(err, "Failed to read request body")
w.WriteHeader(http.StatusInternalServerError)

return
}

defer r.Body.Close()

var alerts []Alert
Expand Down

0 comments on commit adeb58c

Please sign in to comment.