Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

makeRequest doesn't seem to use the cookies set in the HarRequest #2

Open
iriusrisk opened this issue Nov 7, 2013 · 4 comments
Open

Comments

@iriusrisk
Copy link
Collaborator

There's a test in ZAProxyScannerTest called testCookiesWithMakeRequest that illustrates the issue.

Basically, the expected behaviour is this:

  • login to app, that sets a cookie
  • grab a copy of a request that contains the cookie
  • change the value of the cookie in the HarRequest
  • submit the HarRequest with the new cookie using makeRequest
  • The HarEntry returned, should have a HarRequest that contains the new cookie value.

The current behaviour:
The HarRequest contained in HarEntry returned from makeRequest contains the old cookie value.

@ghost ghost assigned thc202 Nov 7, 2013
@iriusrisk
Copy link
Collaborator Author

I've changed the URL for the test web application to: http://localhost:9110/ropeytasks/

@thc202
Copy link
Contributor

thc202 commented Nov 8, 2013

The HTTP request, sent by ZAP, contains the old cookie value because the request is built using the HarRequest's headers field [1] (which contains a Cookie request header with the old cookie value).

The field cookies [2] (the one being changed) is not taken into account to build the request as it's supposed to contain the same cookies as the field headers.

The same applies to other fields that are extracted from other "main" fields (example: queryString and url, with only the latter being used).

Since changing the HarRequest using its setter methods might produce malformed objects (regarding the HAR format) I believe that it would be better to provide an utility class (or an HarRequest builder class) that allows to change its fields while keeping it well-formed. What do you think?

[1] http://www.softwareishard.com/blog/har-12-spec/#headers
[2] http://www.softwareishard.com/blog/har-12-spec/#cookies

@iriusrisk
Copy link
Collaborator Author

Ah, I misunderstood how the harllb worked internally. I've created a utility method:

fcc38c6

Right now, this is all I need for bdd-security, but a general builder will be a better solution going forward. Does the makeRequest set the content-length automatically based on the har content?

@thc202
Copy link
Contributor

thc202 commented Nov 8, 2013

No, it doesn't.

@thc202 thc202 removed their assignment Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant