Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7bf5e448c |
No files matched your search
@@ -71,59 +71,6 @@ func TestServerHasTheFixedLimits(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getOfSize is a GET whose request line and headers, the blank line that ends
|
|
||||||
// them included, are size bytes long.
|
|
||||||
func getOfSize(size int) string {
|
|
||||||
const start, end = "GET / HTTP/1.1\r\nHost: site.example\r\nX-Pad: ", "\r\n\r\n"
|
|
||||||
|
|
||||||
return start + strings.Repeat("x", size-len(start)-len(end)) + end
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestARequestLineAndHeadersOf32KiBReachTheApp(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
standIn := startWAF(t, allow)
|
|
||||||
app := startApp(t, greet)
|
|
||||||
addr, _ := startRProxy(t, standIn.URL, app.URL, nil)
|
|
||||||
|
|
||||||
conn := dial(t, addr)
|
|
||||||
send(t, conn, getOfSize(32<<10))
|
|
||||||
|
|
||||||
if status := readStatus(t, conn); status != http.StatusOK {
|
|
||||||
t.Errorf("status %d, want the app's 200", status)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestARequestLineAndHeadersOver32KiBAreRefusedAndTheConnectionClosed(
|
|
||||||
t *testing.T,
|
|
||||||
) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
standIn := startWAF(t, allow)
|
|
||||||
app := startApp(t, func(http.ResponseWriter, *http.Request) {
|
|
||||||
t.Error("the app was asked")
|
|
||||||
})
|
|
||||||
addr, _ := startRProxy(t, standIn.URL, app.URL, nil)
|
|
||||||
|
|
||||||
conn := dial(t, addr)
|
|
||||||
send(t, conn, getOfSize(32<<10+1))
|
|
||||||
|
|
||||||
// io.ReadAll returns without an error only once rproxy has closed the
|
|
||||||
// connection.
|
|
||||||
text, err := io.ReadAll(conn)
|
|
||||||
if err != nil || !strings.HasPrefix(string(text), "HTTP/1.1 431 ") {
|
|
||||||
t.Errorf(
|
|
||||||
"read %q (%v), want 431 and the connection closed",
|
|
||||||
text,
|
|
||||||
err,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(standIn.questions) != 0 {
|
|
||||||
t.Error("waf was asked")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestABodyAnnouncedOverItsLimitIsRefusedOnceWAFAllowsIt(t *testing.T) {
|
func TestABodyAnnouncedOverItsLimitIsRefusedOnceWAFAllowsIt(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
+6
-9
@@ -14,16 +14,13 @@ set -eu
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
||||||
ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
||||||
|
|
||||||
main() {
|
PUBLISH_IMAGE="git.eeqj.de/sneak/smallwebwaf"
|
||||||
if [ -z "${DOCKER_HOST:-}" ]; then
|
|
||||||
echo "script/publish: DOCKER_HOST is not set; set it to the Docker host that builds the image, such as ssh://user@build.example.com" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -z "${PUBLISH_IMAGE:-}" ]; then
|
|
||||||
echo "script/publish: PUBLISH_IMAGE is not set; set it to the image name in the registry, such as registry.example.com/smallwebwaf" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
main() {
|
||||||
|
|
||||||
|
# we don't set DOCKER_HOST here because the caller is expected to have
|
||||||
|
# either already set it, or used 'docker context' to make 'docker
|
||||||
|
# <whatever>' "just work".
|
||||||
cd "$ROOT"
|
cd "$ROOT"
|
||||||
|
|
||||||
# Own line: a failing command substitution inside an argument does
|
# Own line: a failing command substitution inside an argument does
|
||||||
|
|||||||
Reference in new issue
Block a user