Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apps/api/internal/handler/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,18 @@ func (h *IntegrationHandler) GitHubIssueSummary(c *gin.Context) {
// auth — authentication is the HMAC signature in X-Hub-Signature-256.
// POST /webhooks/github
func (h *IntegrationHandler) GitHubWebhook(c *gin.Context) {
// This route is public (auth is the HMAC signature). Cap the body before
// reading it so an unauthenticated client can't exhaust memory with a huge
// payload. GitHub caps webhook deliveries at 25 MiB.
const maxWebhookBody = 25 << 20
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, maxWebhookBody)
body, err := io.ReadAll(c.Request.Body)
if err != nil {
var tooLarge *http.MaxBytesError
if errors.As(err, &tooLarge) {
c.JSON(http.StatusRequestEntityTooLarge, gin.H{"error": "Payload too large"})
return
}
c.JSON(http.StatusBadRequest, gin.H{"error": "Failed to read body"})
return
}
Expand Down
Loading