Closed (fixed)
Project:
Project Browser
Version:
1.0.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
18 May 2022 at 18:10 UTC
Updated:
10 Jun 2022 at 17:04 UTC
Jump to comment: Most recent
Comments
Comment #2
hooroomooComment #4
hooroomooPlanning to wait till #3281686: Fix incorrect taxonomy term ID in test fixture is in (since it looks like it will be very soon) to rewrite test using the newly introduced helper method from the issue
Comment #5
fjgarlin commentedComment #6
hooroomooComment #7
fjgarlin commentedChanges are simple and tests are provided. Marking as RTBC.
Comment #8
tim.plunkettI'm reviewing this. I have a few questions that I'll try to post soon
Comment #9
tim.plunkettWhy are we doing any XSS filtering on the query string? My understanding is that while it's important to sanitize anything being rendered by us on the front-end, doing string matching should be a 1:1 operation on the input.
For example, consider
\Drupal\block\Controller\CategoryAutocompleteController::autocomplete()which does the comparison on the raw string, and only escapes it for storing the matches that will be rendered later.Unless I'm missing something, I think we should remove those Xss::filter calls, and only escape things if they are being rendered by us, but leave the values intact for the source plugins to do their comparisons.
Comment #10
fjgarlin commentedIf the data is not manipulated and comes from the front-end it will always be ok. However, the endpoints are open and anybody could query them openly within the project and change the URL.
ie: Request URL: https://SITE-URL/drupal-org-proxy/project?page=0&limit=12&sort=usage_tot...
If we are ok passing the request "as is" to the plugins, then yeah, I guess we can remove all the Xss::filter calls from "ProjectBrowserEndpointController". I was probably being over-cautious.
Comment #11
tim.plunkettI think we want to do straight comparisons against the user input, no matter how malformed or even malicious it is. It's up to the plugins to handle that (for example, by using the database API, the MockDrupalDotOrg plugin is protected against SQL injection).
Reassigning to @hooroomoo to remove all of the uses of Xss::filter from this method (other places in the module shouldn't need adjusting)
Comment #12
hooroomooComment #13
fjgarlin commentedIt looks good to me. All Xss::filter removed from the controller as mentioned in the review and tests provided.
Comment #15
tim.plunkettMerged, thanks!
Comment #16
tim.plunkettHmm, this caused failures on PHP 8.1
Sorting changed from PHP 7 to 8, but I'm not sure which part of it caused this problem.
Reverted for now, sorry
Comment #18
fjgarlin commentedComment #20
fjgarlin commentedI created a new branch and recreated the changes from the previous MR: https://git.drupalcode.org/project/project_browser/-/merge_requests/97/d...
The new MR is: https://git.drupalcode.org/project/project_browser/-/merge_requests/114/...
The only change compared to the previous is to add the `$ignore_order` parameter to the function that checks that arrays are the same as the order is only relevant when we're testing order of elements. I'm not sure this covers 100% the PHP8.1 case.Comment #21
fjgarlin commentedRunning the test in PHP8.1 all is green, but it's not in PHP7.3 (see above). The highlighted difference is:
I'm not sure if it's the PHP version or the MySQL version tho.
Comment #22
fjgarlin commentedAs the order is not relevant for this test (and it is related to mysql version, which in turn is really related to how the plugin sorts things) I just changed the placement where the special characters appear.
The rest of the changes should be pretty much as in the original MR.
I'll trigger tests with PHP7.3 and PHP8.1.
Comment #23
fjgarlin commentedComment #24
hooroomooChange looks good to me
Comment #25
fjgarlin commentedComment #27
tim.plunkettI use sqlite locally, and that was the difference. Queued up sqlite with both MRs and it failed the old one and passed the new one!
Thanks for the fixes.