|
35 | 35 | ),
|
36 | 36 | ),
|
37 | 37 | ),
|
| 38 | +}, |
| 39 | +{ |
| 40 | + type => "rule", |
| 41 | + comment => "json parser - issue #1576 - 1", |
| 42 | + conf => qq( |
| 43 | + SecRuleEngine On |
| 44 | + SecRequestBodyAccess On |
| 45 | + SecDebugLog $ENV{DEBUG_LOG} |
| 46 | + SecDebugLogLevel 9 |
| 47 | + SecRule REQUEST_HEADERS:Content-Type "application/json" \\ |
| 48 | + "id:'200001',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON" |
| 49 | + SecRule ARGS "bar" "id:'200441',phase:3,log" |
| 50 | + ), |
| 51 | + match_log => { |
| 52 | + error => [ qr/ModSecurity: Warning. Pattern match "bar" at ARGS:foo.|ModSecurity: JSON support was not enabled/s, 1 ], |
| 53 | + debug => [ qr/ARGS:foo|ARGS:mod|ARGS:ops.ops.ops|ARGS:ops.ops.ops|ARGS:ops.ops|ARGS:ops.ops|ARGS:ops.ops.eins.eins|ARGS:ops.ops.eins.eins|ARGS:whee/, 1 ], |
| 54 | + }, |
| 55 | + match_response => { |
| 56 | + status => qr/^200$/, |
| 57 | + }, |
| 58 | + request => new HTTP::Request( |
| 59 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 60 | + [ |
| 61 | + "Content-Type" => "application/json", |
| 62 | + ], |
| 63 | + normalize_raw_request_data( |
| 64 | + q( |
| 65 | + { |
| 66 | + "foo":"bar", |
| 67 | + "mod":"sec", |
| 68 | + "ops":[ |
| 69 | + [ |
| 70 | + "um", |
| 71 | + "um e meio" |
| 72 | + ], |
| 73 | + "dois", |
| 74 | + "tres", |
| 75 | + { |
| 76 | + "eins":[ |
| 77 | + "zwei", |
| 78 | + "drei" |
| 79 | + ] |
| 80 | + } |
| 81 | + ], |
| 82 | + "whee":"lhebs" |
| 83 | + } |
| 84 | + ), |
| 85 | + ), |
| 86 | + ), |
| 87 | +}, |
| 88 | +{ |
| 89 | + type => "rule", |
| 90 | + comment => "json parser - issue #1576 - 2", |
| 91 | + conf => qq( |
| 92 | + SecRuleEngine On |
| 93 | + SecRequestBodyAccess On |
| 94 | + SecDebugLog $ENV{DEBUG_LOG} |
| 95 | + SecDebugLogLevel 9 |
| 96 | + SecRule REQUEST_HEADERS:Content-Type "application/json" \\ |
| 97 | + "id:'200001',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON" |
| 98 | + SecRule ARGS "um" "id:'200441',phase:3,log" |
| 99 | + ), |
| 100 | + match_log => { |
| 101 | + error => [ qr/ModSecurity: Warning. Pattern match "um" at ARGS:array.array|ModSecurity: JSON support was not enabled/s, 1 ], |
| 102 | + debug => [ qr/ARGS:array.array|ARGS:array.array/, 1 ], |
| 103 | + }, |
| 104 | + match_response => { |
| 105 | + status => qr/^200$/, |
| 106 | + }, |
| 107 | + request => new HTTP::Request( |
| 108 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 109 | + [ |
| 110 | + "Content-Type" => "application/json", |
| 111 | + ], |
| 112 | + normalize_raw_request_data( |
| 113 | + q( |
| 114 | + [ |
| 115 | + "um", |
| 116 | + "um e meio" |
| 117 | + ] |
| 118 | + ), |
| 119 | + ), |
| 120 | + ), |
| 121 | +}, |
| 122 | +{ |
| 123 | + type => "rule", |
| 124 | + comment => "json parser - issue #1576 - 3", |
| 125 | + conf => qq( |
| 126 | + SecRuleEngine On |
| 127 | + SecRequestBodyAccess On |
| 128 | + SecDebugLog $ENV{DEBUG_LOG} |
| 129 | + SecDebugLogLevel 9 |
| 130 | + SecRule REQUEST_HEADERS:Content-Type "application/json" \\ |
| 131 | + "id:'200001',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON" |
| 132 | + SecRule ARGS "seis" "id:'200441',phase:3,log" |
| 133 | + ), |
| 134 | + match_log => { |
| 135 | + error => [ qr/ModSecurity: Warning. Pattern match "seis" at ARGS:array.array.cinco.|ModSecurity: JSON support was not enabled/s, 1 ], |
| 136 | + debug => [ qr/ARGS:array.array|ARGS:array.array|ARGS:array.array.tres|ARGS:array.array.cinco/, 1 ], |
| 137 | + }, |
| 138 | + match_response => { |
| 139 | + status => qr/^200$/, |
| 140 | + }, |
| 141 | + request => new HTTP::Request( |
| 142 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 143 | + [ |
| 144 | + "Content-Type" => "application/json", |
| 145 | + ], |
| 146 | + normalize_raw_request_data( |
| 147 | + q( |
| 148 | + [ |
| 149 | + "um", |
| 150 | + "um e meio", |
| 151 | + { |
| 152 | + "tres": "quatro", |
| 153 | + "cinco": "seis" |
| 154 | + } |
| 155 | + ] |
| 156 | + ), |
| 157 | + ), |
| 158 | + ), |
38 | 159 | }
|
39 | 160 |
|
0 commit comments