Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #3873 Fix premature loop exit in Security Policy lookup of allowe…
…d methods/properties (YSaxon) This PR was squashed before being merged into the 2.x branch. Discussion ---------- Fix premature loop exit in Security Policy lookup of allowed methods/properties The current security policy logic exits too soon when checking permissions for allowed classes and their methods/properties, causing false negatives in situations involving classes related by inheritance. Consider the following configuration: ``` 'methods' => [ 'App\BasicCollection' => ['sortAlphabetically'], 'App\AdvancedCollection'=> ['sortByTimestamp'], ], ``` where `AdvancedCollection` is a subclass of `BasicCollection`, and `mylist` is an instance of `AdvancedCollection` If you try to call `{{ mylist.sortByTimestamp() }}`, the current code will first match `mylist` against `App\BasicCollection`. Since `sortByTimestamp` is not an allowed method for `App\BasicCollection`, the code will exit the loop and incorrectly deny access. It will never get to checking `App\AdvancedCollection`. Note that reordering classes in the config can't solve this issue. If you flipped the order, then it would fail for `{{ mylist.sortAlphabetically() }}` instead. This pull request fixes the issue by only exiting the loop early when both the class and method/property match. Commits ------- 5e1838d Fix premature loop exit in Security Policy lookup of allowed methods/properties
- Loading branch information