|
428 | 428 | ), |
429 | 429 | ), |
430 | 430 | }, |
| 431 | +{ |
| 432 | + type => "rule", |
| 433 | + comment => "xml ProcessPartial, bad value and whole body before limit", |
| 434 | + conf => qq( |
| 435 | + SecRuleEngine On |
| 436 | + SecRequestBodyAccess On |
| 437 | + SecRequestBodyLimitAction ProcessPartial |
| 438 | + SecRequestBodyLimit 61 |
| 439 | + SecXmlExternalEntity Off |
| 440 | + SecDebugLog $ENV{DEBUG_LOG} |
| 441 | + SecDebugLogLevel 9 |
| 442 | + SecRule REQUEST_HEADERS:Content-Type "^text/xml\$" "id:500005, \\ |
| 443 | + phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML" |
| 444 | + SecRule REQBODY_PROCESSOR "!^XML\$" nolog,pass,skipAfter:12345,id:500006 |
| 445 | + SecRule XML:/* "bad_value" "id:'500007',phase:2,t:none,deny" |
| 446 | + ), |
| 447 | + match_log => { |
| 448 | + error => [ qr/Access denied with code 403 \(phase 2\). Pattern match "bad_value" at XML\./, 1 ], |
| 449 | + }, |
| 450 | + match_response => { |
| 451 | + status => qr/^403$/, |
| 452 | + }, |
| 453 | + request => new HTTP::Request( |
| 454 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 455 | + [ |
| 456 | + "Content-Type" => "text/xml", |
| 457 | + ], |
| 458 | + normalize_raw_request_data( |
| 459 | + q(<?xml version="1.0" encoding="utf-8"?><a><b>bad_value</b></a>), |
| 460 | + ), |
| 461 | + ), |
| 462 | +}, |
| 463 | +{ |
| 464 | + type => "rule", |
| 465 | + comment => "xml ProcessPartial, bad value before limit", |
| 466 | + conf => qq( |
| 467 | + SecRuleEngine On |
| 468 | + SecRequestBodyAccess On |
| 469 | + SecRequestBodyLimitAction ProcessPartial |
| 470 | + SecRequestBodyLimit 61 |
| 471 | + SecXmlExternalEntity Off |
| 472 | + SecDebugLog $ENV{DEBUG_LOG} |
| 473 | + SecDebugLogLevel 9 |
| 474 | + SecRule REQUEST_HEADERS:Content-Type "^text/xml\$" "id:500005, \\ |
| 475 | + phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML" |
| 476 | + SecRule REQBODY_PROCESSOR "!^XML\$" nolog,pass,skipAfter:12345,id:500006 |
| 477 | + SecRule XML:/* "bad_value" "id:'500007',phase:2,t:none,deny" |
| 478 | + ), |
| 479 | + match_log => { |
| 480 | + error => [ qr/Access denied with code 403 \(phase 2\). Pattern match "bad_value" at XML\./, 1 ], |
| 481 | + }, |
| 482 | + match_response => { |
| 483 | + status => qr/^403$/, |
| 484 | + }, |
| 485 | + request => new HTTP::Request( |
| 486 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 487 | + [ |
| 488 | + "Content-Type" => "text/xml", |
| 489 | + ], |
| 490 | + normalize_raw_request_data( |
| 491 | + q(<?xml version="1.0" encoding="utf-8"?><a><b>bad_value</b><c>ok_value</c></a>), |
| 492 | + ), |
| 493 | + ), |
| 494 | +}, |
| 495 | +{ |
| 496 | + type => "rule", |
| 497 | + comment => "xml ProcessPartial, bad value after limit", |
| 498 | + conf => qq( |
| 499 | + SecRuleEngine On |
| 500 | + SecRequestBodyAccess On |
| 501 | + SecRequestBodyLimitAction ProcessPartial |
| 502 | + SecRequestBodyLimit 61 |
| 503 | + SecXmlExternalEntity Off |
| 504 | + SecDebugLog $ENV{DEBUG_LOG} |
| 505 | + SecDebugLogLevel 9 |
| 506 | + SecRule REQUEST_HEADERS:Content-Type "^text/xml\$" "id:500005, \\ |
| 507 | + phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML" |
| 508 | + SecRule REQBODY_PROCESSOR "!^XML\$" nolog,pass,skipAfter:12345,id:500006 |
| 509 | + SecRule XML:/* "bad_value" "id:'500007',phase:2,t:none,deny" |
| 510 | + ), |
| 511 | + match_response => { |
| 512 | + status => qr/^200$/, |
| 513 | + }, |
| 514 | + request => new HTTP::Request( |
| 515 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 516 | + [ |
| 517 | + "Content-Type" => "text/xml", |
| 518 | + ], |
| 519 | + normalize_raw_request_data( |
| 520 | + q(<?xml version="1.0" encoding="utf-8"?><a><b>12</b><c>bad_value</c></a>), |
| 521 | + ), |
| 522 | + ), |
| 523 | +}, |
0 commit comments