Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

fix url parsing for forwarded url after route-service pass#247

Merged
tylerschultz merged 2 commits intocloudfoundry:masterfrom
otaviojacobi:forwarded-url-parsing-fix
Mar 11, 2019
Merged

fix url parsing for forwarded url after route-service pass#247
tylerschultz merged 2 commits intocloudfoundry:masterfrom
otaviojacobi:forwarded-url-parsing-fix

Conversation

@otaviojacobi
Copy link
Copy Markdown
Contributor

@otaviojacobi otaviojacobi commented Feb 15, 2019

A short explanation of the proposed change:

See #246 - This PR changes the url.Parse to url.ParseRequestURI in the handlers.validateRouteServicePool method. The main reason for that is that url.Parse tries to strip out the # from the unescaped ForwardedUrl which when followed by a % character results in an error. The url.ParseRequestURI doesn't have this problem since it considers that the request doesn't have a #fragment.

An explanation of the use cases your change solves

Requests that pass through the gorouter and have a bound route-service, during the second pass through the gorouter, if the request has a escaped character # followed by a escaped % (as https://my-cf-route.my.cf.domain/test?findById='%23%25') throw an Invalid Signature Error but the request is fine and should be properly forwarded to the backing service.

Instructions to functionally test the behavior change using operator interfaces (BOSH manifest, logs, curl, and metrics)

  • create a simple backend service to be routed.
  • create a route-service that simply reverse-proxy the request to the backend service
  • create a user provided service from the created route-service
  • bind the user provided service to the simple backend service
  • make a request with a query as ?testquery=%23%25

Expected result after the change

All requests with well formed URL should pass through the gorouter with a route-service and the request above should be forwarded to the backend service

Current result before the change

Impossible to make requests that have a escaped character #(%23) followed by a escaped character %(%25) as the gorouter throws an Invalid Signature Error

Links to any other associated PRs

This fixes #246

  • I have viewed signed and have submitted the Contributor License Agreement

  • I have made this pull request to the master branch

  • I have run all the unit tests using bin/test

  • I have run CF Acceptance Tests on bosh lite

@cfdreddbot
Copy link
Copy Markdown

❌ Hey otaviojacobi!

All pull request submitters and commit authors must have a Contributor License Agreement (CLA). Click here for details on the CLA process.

The following github user @otaviojacobi is not covered by a CLA.

After the CLA process is complete, this pull request will need to be closed & reopened. DreddBot will then validate the CLA(s).

@cf-gitbot
Copy link
Copy Markdown

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/164023544

The labels on this github issue will be updated when the story is started.

@cfdreddbot
Copy link
Copy Markdown

❌ Hey otaviojacobi!

All pull request submitters and commit authors must have a Contributor License Agreement (CLA). Click here for details on the CLA process.

The following github user @otaviojacobi is not covered by a CLA.

After the CLA process is complete, this pull request will need to be closed & reopened. DreddBot will then validate the CLA(s).

@cf-gitbot
Copy link
Copy Markdown

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/164047160

The labels on this github issue will be updated when the story is started.

@cfdreddbot
Copy link
Copy Markdown

✅ Hey otaviojacobi! The commit authors and yourself have already signed the CLA.

@cf-gitbot
Copy link
Copy Markdown

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/164047662

The labels on this github issue will be updated when the story is started.

It("strips headers and sends the request to the backend instance", func() {
handler.ServeHTTP(resp, req)

Expect(resp.Code).To(Equal(http.StatusTeapot))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like everything passed this code test could be removed. This is really what we are testing. All the rest if just the same as the test just above. We don't need to test again that it "strips headers and sends the request to the backend instance", but just that there are no errors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea for the other checks was that we assure that we were not breaking anything from the test above when using the special sequence of characters. But I can see why it is test duplication, therefore I'll remove the other checks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I have updated the PR so now the test doesn't test again the same as the above, but only the necessary.

@tylerschultz tylerschultz merged commit 99b6773 into cloudfoundry:master Mar 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to validate Route Service Signature

5 participants