-
Notifications
You must be signed in to change notification settings - Fork 69
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
Update the API client to validate route params before making a request #9030
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: 0 B Total Size: 1.26 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this issue, but I don't think the suggestion is the right way to go, as explained below.
includes/admin/class-wc-rest-payments-authorizations-controller.php
Outdated
Show resolved
Hide resolved
…/woocommerce-payments into update/route-regex-validation
This reverts commit 5481ff0.
…/woocommerce-payments into update/route-regex-validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Only note is that maybe we can have a dedicated method to validate ID and throw an exception and re-use it in the affected places?
I considered it but then thought different methods could also check for other conditions related to that param maybe and having it in the method itself might be more flexible, don't have a strong usecase for this at the top of my head except for length check in some cases like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested challenging dispute and it worked.
However, I check all the request()
calls in wc-payment-api/class-wc-payments-api-client.php
and found $customer_id
is not validated here.
$product_id
is not validated as well here.
There are more cases like that where parameter that is passed as part of the request URL, is not validated.
Are those out of this PR's scope?
@shendy-a8c Wherever there was an existing validation for the param being passed, we didn't update that to defer to the existing checks. Update: Added validation for missing places as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Fixes https://github.com/Automattic/woocommerce-payments-server/issues/1548
Changes proposed in this Pull Request
Testing instructions
npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge