Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/request_body_processor/multipart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,10 @@ int Multipart::multipart_complete(std::string *error) {
"Multipart: Warning: invalid header folding used.");
}

m_transaction->m_variableMultipartFileLimitExceeded.set(
std::to_string(m_flag_file_limit_exceeded),
m_transaction->m_variableOffset);

m_transaction->m_variableMultipartStrictError.set(
std::to_string(m_flag_error || m_flag_boundary_quoted != 0
|| m_flag_boundary_whitespace != 0 || m_flag_data_before != 0
Expand Down
33 changes: 17 additions & 16 deletions test/test-cases/regression/request-body-parser-multipart.json
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@
},
"expected": {
"debug_log": "boundary whitespace in C-T header",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 1,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 1,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -1587,7 +1587,7 @@
]
},
"expected": {
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -1650,7 +1650,7 @@
},
"expected": {
"debug_log": "No boundaries found in payload",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 1,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 1,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -1713,7 +1713,7 @@
},
"expected": {
"debug_log": "Invalid boundary in C-T \\(characters\\)",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -1776,7 +1776,7 @@
},
"expected": {
"debug_log": "boundary was quoted",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -1839,7 +1839,7 @@
},
"expected": {
"debug_log": "boundary was quoted.*No boundaries found in payload",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -1902,7 +1902,7 @@
},
"expected": {
"debug_log": "Invalid boundary in C-T \\(characters\\).*boundary was quoted.",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -1965,7 +1965,7 @@
},
"expected": {
"debug_log": "Invalid boundary in C-T \\(characters\\).*boundary was quoted.",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -2028,7 +2028,7 @@
},
"expected": {
"debug_log": "boundary was quoted",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -2091,7 +2091,7 @@
},
"expected": {
"debug_log": "Invalid boundary in C-T \\(characters\\)",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -2154,7 +2154,7 @@
},
"expected": {
"debug_log": "Invalid boundary in C-T \\(characters\\)",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 1,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -2217,7 +2217,7 @@
},
"expected": {
"debug_log": "Invalid boundary in C-T \\(quote\\)",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -2280,7 +2280,7 @@
},
"expected": {
"debug_log": "Invalid boundary in C-T \\(quote\\)",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 0,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -2353,7 +2353,7 @@
},
"expected": {
"debug_log": "Invalid Content-Disposition header",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 1,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 1,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -2425,7 +2425,7 @@
},
"expected": {
"debug_log": "Part missing Content-Disposition header",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 1,IH 0,FL \"",
"error_log": "msg \"Multipart request body failed strict validation:PE 1,BQ 0,BW 0,DB 0,DA 0,HF 0,LF 0,SM 0,IQ 0,IP 1,IH 0,FL 0\"",
"http_code": 403
},
"rules": [
Expand Down Expand Up @@ -2502,6 +2502,7 @@
},
"expected": {
"debug_log": "Upload file limit exceeded",
"error_log": "Check variable for test:FL 1",
"http_code": 403
},
"rules": [
Expand All @@ -2511,7 +2512,7 @@
"SecUploadFileLimit 2",
"SecRule MULTIPART_STRICT_ERROR \"!@eq 1\" \"phase:2,deny,id:500161\"",
"SecRule MULTIPART_FILE_LIMIT_EXCEEDED \"!@eq 1\" \"phase:2,deny,id:500162\"",
"SecRule REQBODY_PROCESSOR_ERROR \"@eq 1\" \"phase:2,deny,id:500163\"",
"SecRule REQBODY_PROCESSOR_ERROR \"@eq 1\" \"phase:2,deny,id:500163,msg:'Check variable for test:FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'\"",
"SecRule &FILES \"!@eq 3\" \"phase:2,deny,id:500164\"",
"SecRule &FILES_NAMES \"!@eq 3\" \"phase:2,deny,id:500165\"",
"SecRule &FILES_SIZES \"!@eq 3\" \"phase:2,deny,id:500166\"",
Expand Down
Loading