|
36 | 36 | import org.parosproxy.paros.network.HttpHeader; |
37 | 37 | import org.parosproxy.paros.network.HttpMalformedHeaderException; |
38 | 38 | import org.parosproxy.paros.network.HttpMessage; |
| 39 | +import org.parosproxy.paros.network.HttpRequestHeader; |
39 | 40 | import org.zaproxy.zap.core.scanner.InputVector.PayloadFormat; |
40 | 41 | import org.zaproxy.zap.core.scanner.InputVectorBuilder; |
41 | 42 |
|
@@ -312,6 +313,53 @@ void shouldExtractParametersFromAllPartsEvenIfSomeAreEmpty() { |
312 | 313 | is(equalTo(NameValuePair.TYPE_MULTIPART_DATA_FILE_PARAM))); |
313 | 314 | } |
314 | 315 |
|
| 316 | + @Test |
| 317 | + void shouldExtractParametersWhenBoundyHasMixedCapitalization() |
| 318 | + throws HttpMalformedHeaderException { |
| 319 | + // Given |
| 320 | + VariantMultipartFormParameters variant = new VariantMultipartFormParameters(); |
| 321 | + HttpRequestHeader reqHdr = |
| 322 | + new HttpRequestHeader( |
| 323 | + """ |
| 324 | + POST https://127.0.0.1:8000/login HTTP/1.1 |
| 325 | + host: 127.0.0.1:8000 |
| 326 | + User-Agent: curl/8.7.1 |
| 327 | + Accept: */* |
| 328 | + Content-Length: 282 |
| 329 | + Content-Type: multipart/form-data; boundary=------------------------o4XsAqQ54LPupcrI0dfahp |
| 330 | + """); |
| 331 | + String body = |
| 332 | + """ |
| 333 | + --------------------------o4XsAqQ54LPupcrI0dfahp\r |
| 334 | + Content-Disposition: form-data; name="email"\r |
| 335 | + \r |
| 336 | + test@example.com\r |
| 337 | + --------------------------o4XsAqQ54LPupcrI0dfahp\r |
| 338 | + Content-Disposition: form-data; name="password"\r |
| 339 | + \r |
| 340 | + testpass123\r |
| 341 | + --------------------------o4XsAqQ54LPupcrI0dfahp--\r |
| 342 | + \r |
| 343 | + """; |
| 344 | + HttpMessage message = new HttpMessage(reqHdr); |
| 345 | + message.setRequestBody(body); |
| 346 | + // When |
| 347 | + variant.setMessage(message); |
| 348 | + // Then |
| 349 | + assertThat(variant.getParamList().get(0).getPosition(), is(equalTo(1))); |
| 350 | + assertThat(variant.getParamList().get(0).getName(), is(equalTo("email"))); |
| 351 | + assertThat(variant.getParamList().get(0).getValue(), is(equalTo("test@example.com"))); |
| 352 | + assertThat( |
| 353 | + variant.getParamList().get(0).getType(), |
| 354 | + is(equalTo(NameValuePair.TYPE_MULTIPART_DATA_PARAM))); |
| 355 | + assertThat(variant.getParamList().get(1).getPosition(), is(equalTo(2))); |
| 356 | + assertThat(variant.getParamList().get(1).getName(), is(equalTo("password"))); |
| 357 | + assertThat(variant.getParamList().get(1).getValue(), is(equalTo("testpass123"))); |
| 358 | + assertThat( |
| 359 | + variant.getParamList().get(1).getType(), |
| 360 | + is(equalTo(NameValuePair.TYPE_MULTIPART_DATA_PARAM))); |
| 361 | + } |
| 362 | + |
315 | 363 | @Test |
316 | 364 | void shouldInjectParamValueModificationInGeneralParam() { |
317 | 365 | // Given |
|
0 commit comments