What your framework never told you about SQL injection protection
codeyellow.nl
codeyellow.nl
$resulset->search({ column1 => some_sub($arg), column2 => $value2, ...});
Many subs may behave in unexpected ways when using list context, such as returning an empty list. You may end up with values, which are normally escaped, becoming keys in the hashref. DBIC only does the simplest of checks on the key values, leaving your code open to an SQL injection.
This sort of issue is unfortunately prevalent. It is not just limited to PHP and dismissing it as such does everyone a disservice.
I am interested in removing all and any attack vectors, but I can't fix problems without knowing about them. So please do get back to me on this.
Cheers
You'd then have to validate the input (horrors!) and then add the appropriate sort order to the query (builder) in your own code.
Thus you present the user with column labels such as "Item", "Description", "Weight", "Packing volume", "List Price", which internally map to something like %sort_orders = { 'Item' => \&item_sort_order, 'Description' => \&description_sort_order, … } with your code doing a lookup along the lines of if exists $sort_orders{$request_sort_label} …
Of course this isn't going to be as simple and elegant as allowing user input to pass directly into your database engine.
But then for every problem there is at least one answer which is simple, elegant, and completely wrong.
This isn't a PHP specific problem of course but I do wonder if it is a sign that frameworks in general shouldn't come with their own ORMs. Although, having seen PHP running in the wild that doesn't even bother escaping strings into SQL, I have to think that at the very least using a framework makes things safer if not safe, and makes fixing this crap easier.