mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-26 08:39:06 +02:00
Add CrowdSec AppSec request inspection to the reverse proxy
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package netutil
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"golang.org/x/net/http/httpguts"
|
||||
)
|
||||
|
||||
// IsUpgradeRequest reports whether r is a protocol-upgrade request, using the
|
||||
// same predicate httputil.ReverseProxy applies when it decides to hand the
|
||||
// connection over instead of proxying normally.
|
||||
//
|
||||
// Matching the forwarder exactly matters for anything that inspects a request
|
||||
// before it is proxied: a looser test (an Upgrade header on its own, say) marks
|
||||
// a request as an upgrade and skips inspection, while the forwarder still
|
||||
// delivers it to the backend as an ordinary request with its body intact. That
|
||||
// gap is a body-inspection bypass reachable by adding one header.
|
||||
func IsUpgradeRequest(h http.Header) bool {
|
||||
if !httpguts.HeaderValuesContainsToken(h["Connection"], "Upgrade") {
|
||||
return false
|
||||
}
|
||||
return h.Get("Upgrade") != ""
|
||||
}
|
||||
Reference in New Issue
Block a user