41
41
server_name localhost;
42
42
43
43
modsecurity on;
44
+ client_header_buffer_size 1024;
44
45
45
46
location /bodyaccess {
46
47
modsecurity_rules '
@@ -82,14 +83,28 @@ http {
82
83
';
83
84
proxy_pass http://127.0.0.1:8081;
84
85
}
86
+
87
+ location = /auth {
88
+ return 200;
89
+ }
90
+
91
+ location = /useauth {
92
+ modsecurity on;
93
+ modsecurity_rules '
94
+ SecRuleEngine On
95
+ SecRequestBodyAccess On
96
+ ';
97
+ auth_request /auth;
98
+ proxy_pass http://127.0.0.1:8081;
99
+ }
85
100
}
86
101
}
87
102
EOF
88
103
89
104
$t -> run_daemon(\&http_daemon);
90
105
$t -> run()-> waitforsocket(' 127.0.0.1:' . port(8081));
91
106
92
- $t -> plan(32 );
107
+ $t -> plan(36 );
93
108
94
109
# ##############################################################################
95
110
@@ -104,6 +119,31 @@ like(http_req_body($method, '/bodylimitprocesspartial', 'BODY' x 32 . 'BAD BODY'
104
119
like(http_req_body($method , ' /bodylimitprocesspartial' , ' BODY' x 30 . ' BAD BODY' x 32 ), qr / 403 Forbidden/ , " $method request body limit process partial, block" );
105
120
}
106
121
122
+ like(http_req_body(' POST' , ' /useauth' , ' BODY' x 16 ), qr / TEST-OK-IF-YOU-SEE-THIS/ , " POST with auth_request (request size < client_header_buffer_size)" );
123
+ like(http_req_body(' POST' , ' /useauth' , ' BODY' x 257 ), qr / TEST-OK-IF-YOU-SEE-THIS/ , " POST with auth_request (request size > client_header_buffer_size)" );
124
+
125
+ like(
126
+ http(
127
+ ' POST /useauth HTTP/1.0' . CRLF
128
+ . ' Content-Length: 1028' . CRLF . CRLF
129
+ . ' BODY' x 256 ,
130
+ sleep => 0.1,
131
+ body => ' BODY'
132
+ ),
133
+ qr / TEST-OK-IF-YOU-SEE-THIS/ ,
134
+ ' POST with auth_request (request size > client_header_buffer_size), no preread'
135
+ );
136
+
137
+ like(
138
+ http(
139
+ ' POST /useauth HTTP/1.0' . CRLF
140
+ . ' Content-Length: 64' . CRLF . CRLF
141
+ . ' BODY' x 16
142
+ ),
143
+ qr / TEST-OK-IF-YOU-SEE-THIS/ ,
144
+ ' POST with auth_request (request size < client_header_buffer_size), no preread'
145
+ );
146
+
107
147
# ##############################################################################
108
148
109
149
sub http_daemon {
0 commit comments