|
428 | 428 | ), |
429 | 429 | ), |
430 | 430 | }, |
| 431 | +{ |
| 432 | + type => "rule", |
| 433 | + comment => "xml ProcessPartial, bad format and whole body before limit", |
| 434 | + conf => qq( |
| 435 | + SecRuleEngine On |
| 436 | + SecRequestBodyAccess On |
| 437 | + SecRequestBodyLimitAction ProcessPartial |
| 438 | + SecRequestBodyLimit 57 |
| 439 | + SecRequestBodyNoFilesLimit 57 |
| 440 | + SecXmlExternalEntity Off |
| 441 | + SecDebugLog $ENV{DEBUG_LOG} |
| 442 | + SecDebugLogLevel 9 |
| 443 | + SecRule REQUEST_HEADERS:Content-Type "^text/xml\$" "id:500005, \\ |
| 444 | + phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML" |
| 445 | + SecRule REQBODY_PROCESSOR "!^XML\$" nolog,pass,skipAfter:12345,id:500006 |
| 446 | + SecRule REQBODY_ERROR "!\@eq 0" \\ |
| 447 | + "id:'500007', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2" |
| 448 | + SecRule XML:/* "bad_value" "id:'500008',phase:2,t:none,deny" |
| 449 | + ), |
| 450 | + match_log => { |
| 451 | + error => [ qr/Access denied with code 400 \(phase 2\). Match of "eq 0" against "REQBODY_ERROR" required\./, 1 ], |
| 452 | + }, |
| 453 | + match_response => { |
| 454 | + status => qr/^400$/, |
| 455 | + }, |
| 456 | + request => new HTTP::Request( |
| 457 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 458 | + [ |
| 459 | + "Content-Type" => "text/xml", |
| 460 | + "Content-Length" => "57", |
| 461 | + ], |
| 462 | + '<?xml version="1.0" encoding="utf-8"?><a><b>value</b></a ', |
| 463 | + ), |
| 464 | +}, |
| 465 | +{ |
| 466 | + type => "rule", |
| 467 | + comment => "xml ProcessPartial, bad format and length exceeds limit", |
| 468 | + conf => qq( |
| 469 | + SecRuleEngine On |
| 470 | + SecRequestBodyAccess On |
| 471 | + SecRequestBodyLimitAction ProcessPartial |
| 472 | + SecRequestBodyLimit 57 |
| 473 | + SecRequestBodyNoFilesLimit 57 |
| 474 | + SecXmlExternalEntity Off |
| 475 | + SecDebugLog $ENV{DEBUG_LOG} |
| 476 | + SecDebugLogLevel 9 |
| 477 | + SecRule REQUEST_HEADERS:Content-Type "^text/xml\$" "id:500005, \\ |
| 478 | + phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML" |
| 479 | + SecRule REQBODY_PROCESSOR "!^XML\$" nolog,pass,skipAfter:12345,id:500006 |
| 480 | + SecRule REQBODY_ERROR "!\@eq 0" \\ |
| 481 | + "id:'500007', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2" |
| 482 | + SecRule XML:/* "bad_value" "id:'500008',phase:2,t:none,deny" |
| 483 | + ), |
| 484 | + match_log => { |
| 485 | + -error => [ qr/Access denied with code 400 \(phase 2\). Match of "eq 0" against "REQBODY_ERROR" required\./, 1 ], |
| 486 | + }, |
| 487 | + match_response => { |
| 488 | + status => qr/^200$/, |
| 489 | + }, |
| 490 | + request => new HTTP::Request( |
| 491 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 492 | + [ |
| 493 | + "Content-Type" => "text/xml", |
| 494 | + "Content-Length" => "58", |
| 495 | + ], |
| 496 | + '<?xml version="1.0" encoding="utf-8"?><a><b>value</b></a ', |
| 497 | + ), |
| 498 | +}, |
| 499 | +{ |
| 500 | + type => "rule", |
| 501 | + comment => "xml ProcessPartial, bad format and whole body before limit, no declaration", |
| 502 | + conf => qq( |
| 503 | + SecRuleEngine On |
| 504 | + SecRequestBodyAccess On |
| 505 | + SecRequestBodyLimitAction ProcessPartial |
| 506 | + SecRequestBodyLimit 19 |
| 507 | + SecRequestBodyNoFilesLimit 19 |
| 508 | + SecXmlExternalEntity Off |
| 509 | + SecDebugLog $ENV{DEBUG_LOG} |
| 510 | + SecDebugLogLevel 9 |
| 511 | + SecRule REQUEST_HEADERS:Content-Type "^text/xml\$" "id:500005, \\ |
| 512 | + phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML" |
| 513 | + SecRule REQBODY_PROCESSOR "!^XML\$" nolog,pass,skipAfter:12345,id:500006 |
| 514 | + SecRule REQBODY_ERROR "!\@eq 0" \\ |
| 515 | + "id:'500007', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2" |
| 516 | + SecRule XML:/* "bad_value" "id:'500008',phase:2,t:none,deny" |
| 517 | + ), |
| 518 | + match_log => { |
| 519 | + error => [ qr/Access denied with code 400 \(phase 2\). Match of "eq 0" against "REQBODY_ERROR" required\./, 1 ], |
| 520 | + }, |
| 521 | + match_response => { |
| 522 | + status => qr/^400$/, |
| 523 | + }, |
| 524 | + request => new HTTP::Request( |
| 525 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 526 | + [ |
| 527 | + "Content-Type" => "text/xml", |
| 528 | + "Content-Length" => "19", |
| 529 | + ], |
| 530 | + '<a><b>value</b></a ', |
| 531 | + ), |
| 532 | +}, |
| 533 | +{ |
| 534 | + type => "rule", |
| 535 | + comment => "xml ProcessPartial, bad format and length exceeds limit, no declaration", |
| 536 | + conf => qq( |
| 537 | + SecRuleEngine On |
| 538 | + SecRequestBodyAccess On |
| 539 | + SecRequestBodyLimitAction ProcessPartial |
| 540 | + SecRequestBodyLimit 19 |
| 541 | + SecRequestBodyNoFilesLimit 19 |
| 542 | + SecXmlExternalEntity Off |
| 543 | + SecDebugLog $ENV{DEBUG_LOG} |
| 544 | + SecDebugLogLevel 9 |
| 545 | + SecRule REQUEST_HEADERS:Content-Type "^text/xml\$" "id:500005, \\ |
| 546 | + phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML" |
| 547 | + SecRule REQBODY_PROCESSOR "!^XML\$" nolog,pass,skipAfter:12345,id:500006 |
| 548 | + SecRule REQBODY_ERROR "!\@eq 0" \\ |
| 549 | + "id:'500007', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2" |
| 550 | + SecRule XML:/* "bad_value" "id:'500008',phase:2,t:none,deny" |
| 551 | + ), |
| 552 | + match_log => { |
| 553 | + -error => [ qr/Access denied with code 400 \(phase 2\). Match of "eq 0" against "REQBODY_ERROR" required\./, 1 ], |
| 554 | + }, |
| 555 | + match_response => { |
| 556 | + status => qr/^200$/, |
| 557 | + }, |
| 558 | + request => new HTTP::Request( |
| 559 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 560 | + [ |
| 561 | + "Content-Type" => "text/xml", |
| 562 | + "Content-Length" => "20", |
| 563 | + ], |
| 564 | + '<a><b>value</b></a ', |
| 565 | + ), |
| 566 | +}, |
431 | 567 | { |
432 | 568 | type => "rule", |
433 | 569 | comment => "xml ProcessPartial, bad value and whole body before limit", |
|
0 commit comments