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

Curl: Check all responses for protected cookies #13326

Merged

Conversation

samford
Copy link
Member

@samford samford commented May 25, 2022

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

The response from a URL protected by Cloudflare may only provide a relevant cookie on the first response but #curl_http_content_headers_and_checksum only returns the headers of the final response. In this scenario, #curl_check_http_content isn't able to properly detect the protected URL and this is surfaced as an error instead of skipping the URL (see Homebrew/homebrew-cask#124277).

This PR resolves the issue by including the array of response hashes in the return value from #curl_http_content_headers_and_checksum, so we can check all the responses in #curl_check_http_content.

Besides that, this also renames the :status key in the return hash from #curl_http_content_headers_and_checksum to :status_code. This aligns the key name with the return hash from #parse_curl_response and technically allows us to pass either hash to the #url_protected_by_* methods (as they both contain :status_code and :headers in the expected format. This felt like a nicer way of approaching the switch from the details hash to a response hash.

@samford samford added the critical Critical change which should be shipped as soon as possible. label May 25, 2022
@BrewTestBot
Copy link
Member

Review period skipped due to critical label.

@samford samford force-pushed the curl/check-all-responses-for-protected-cookies branch from 46ddd39 to e1c627e Compare May 25, 2022 18:01
samford added 2 commits May 25, 2022 16:50
The return hash from `#curl_http_content_headers_and_checksum`
contains a `:status`, which is the status code of the last response.
This string value comes from `#parse_curl_response`, where the key is
`:status_code` instead.

Aligning these keys technically allows us to pass either of these
hashes to the `#url_protected_by_*` methods, as both contain
`:status_code` and `:headers` in the expected format.
The response from a URL protected by Cloudflare may only provide a
relevant cookie on the first response but
`#curl_http_content_headers_and_checksum` only returns the headers of
the final response. In this scenario, `#curl_check_http_content` isn't
able to properly detect the protected URL and this is surfaced as an
error instead of skipping the URL.

This resolves the issue by including the array of response hashes in
the return value from `#curl_http_content_headers_and_checksum`, so
we can check all the responses in `#curl_check_http_content`.
@samford samford force-pushed the curl/check-all-responses-for-protected-cookies branch from e1c627e to 403a4d4 Compare May 25, 2022 20:50
@samford samford merged commit 1c1a720 into Homebrew:master May 25, 2022
@samford samford deleted the curl/check-all-responses-for-protected-cookies branch May 25, 2022 21:31
@github-actions github-actions bot added the outdated PR was locked due to age label Jun 25, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
critical Critical change which should be shipped as soon as possible. outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants