Skip to content

Commit

Permalink
Add ReadHeaderTimeout for security
Browse files Browse the repository at this point in the history
Closes #821

Signed-off-by: Doug Davis <dug@microsoft.com>
  • Loading branch information
Doug Davis committed Dec 8, 2022
1 parent 2298be0 commit 54d75c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions v2/protocol/http/abuse_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type WebhookConfig struct {

const (
DefaultAllowedRate = 1000
DefaultReadTimeout = time.Second * 600
)

// TODO: implement rate limiting.
Expand Down
6 changes: 4 additions & 2 deletions v2/protocol/http/protocol_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net"
"net/http"
"strings"
"time"

"github.com/cloudevents/sdk-go/v2/protocol"
)
Expand Down Expand Up @@ -38,8 +39,9 @@ func (p *Protocol) OpenInbound(ctx context.Context) error {
}

p.server = &http.Server{
Addr: listener.Addr().String(),
Handler: attachMiddleware(p.Handler, p.middleware),
Addr: listener.Addr().String(),
Handler: attachMiddleware(p.Handler, p.middleware),
ReadHeaderTimeout: DefaultReadTimeout,
}

// Shutdown
Expand Down

0 comments on commit 54d75c1

Please sign in to comment.