![]() |
09-05-2024, 11:05 PM
(This post was last modified: 09-09-2024, 09:31 AM by libsys. Edit Reason: is > if ) (09-04-2024, 08:52 AM)Renta Ardhana Wrote: Why do you modify the $allowedFields after declaring it in the Model? I was not modifying $allowedFields, I said that to exemplify the unique ways I could have stuff protected from mass assignment vulnerabilities while using $allowedFields. (09-04-2024, 08:52 AM)Renta Ardhana Wrote: As far as I know, an entity's attributes should be immutable, or if you want to make transformations, they should be done through a setter/getter. Even if I had immutable entities, I would need to list every field in $allowedFields. Even if I modify stuff with setters, I still need to put those fields in $allowedFields. IMHO the current approach is problematic because there's no easy way to explicitly insert protected data in the database, ever, no matter if massively assigned or not. Other frameworks (such as Laravel) discard attributes only on mass assignment (but not on manual assignment). When using CI4 entities, currently there's no way to know if a field has been massively assigned or individually. In order to actually have the protection I expected, now I am indeed modifying the model's $allowedFields when setting fields manually in entities. Here is what I'm doing: BaseModel.php PHP Code: <?php BaseEntity.php PHP Code: <?php Usage examples: PHP Code: // 1 |
Messages In This Thread |
How does $allowedFields protect against mass assignment vulnerabilities? - by libsys - 09-03-2024, 08:06 AM
RE: How does $allowedFields protect against mass assignment vulnerabilities? - by Renta Ardhana - 09-04-2024, 08:52 AM
RE: How does $allowedFields protect against mass assignment vulnerabilities? - by kenjis - 09-04-2024, 11:59 PM
RE: How does $allowedFields protect against mass assignment vulnerabilities? - by libsys - 09-05-2024, 11:05 PM
RE: How does $allowedFields protect against mass assignment vulnerabilities? - by kenjis - 09-06-2024, 04:56 PM
RE: How does $allowedFields protect against mass assignment vulnerabilities? - by libsys - 09-09-2024, 08:57 AM
|