[6.x] Verify column names are actual columns when using guarded - #33777
Merged
Conversation
Contributor
|
@driesvints @GrahamCampbell could you explain the reasoning behind this change? It broke some functionality in @octobercms, see octobercms/library@b779df0 |
Collaborator
driesvints
pushed a commit
that referenced
this pull request
Aug 13, 2020
* verify column names are actual columns when using guarded * Apply fixes from StyleCI (#33778) * remove json check
taylorotwell
added a commit
that referenced
this pull request
Aug 13, 2020
* fix casing issue with guarded * block json mass assignment * formatting * add boolean * protect table names and guarded * Apply fixes from StyleCI (#33772) * dont allow mass filling with table names * Apply fixes from StyleCI (#33773) * [6.x] Verify column names are actual columns when using guarded (#33777) * verify column names are actual columns when using guarded * Apply fixes from StyleCI (#33778) * remove json check * Apply fixes from StyleCI (#33857) Co-authored-by: Taylor Otwell <taylorotwell@gmail.com> Co-authored-by: Taylor Otwell <taylor@laravel.com>
Contributor
|
I've used Eloquent mutators/accessors to create virtual model columns in the past, but this change suggests that was never part of intended usage (otherwise we'd need to check for a method name within |
Contributor
|
That's correct @shengslogar, see octobercms/library@b779df0#commitcomment-41334767 |
fulopattila122
added a commit
to vanilophp/cart
that referenced
this pull request
Sep 24, 2020
The reason behind is that Laravel 6.18.35 & 7.24.0 introduced a security improvement that prevents from mass assigning non-db fields to an Eloquent model. The implementation is holding a reference to the list of the table fields in the newly introduced `guardableColumns` static property. It gets populated with the fields from the db for the first time a mass assignment happens on a model. In our tests, we add fields to the cart_items table during testing. If we hit the model first with the original amount of fields, the second call - having the new fields in the underlying table - won't repopulate the `guardableColumns` static property - for obvious reasons. However, there's no facility to reset this list, therefore we can't reboot this property of a model within a single run of a PHP process (namely tests). A dirty fix was to move the test with the extended number of columns ahead, thus those columns will be populated. Cheap fix, but actually in a real application it's not the case, it's only causing problems with testing. Thus, we get away with it. We have more important stuff to take care of ;) - See: https://blog.laravel.com/security-release-laravel-61835-7240 - See: laravel/framework#33777
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR will verify column names are actual columns on the database when using guarded with explicit column names.