Hi All,
As Nuno already said, those sanitation type of actions work on sql literals, not on parts of the sql clause, as sort by is.
So, as Vincent is saying, I don't think you can necessarily make the warning go away. But you can still mitigate the dangers this warning is for, right ?
I don't know how complex your sorting is, but if it's just the standard "click on the column header to sort by that attribute, click again to sort descending" type of approach, then just build a function checking the TableSort string against the attributes in the entity, anything else, log a message and apply some standard sorting.
See attached oml for a simple reactive example, it will of course get more complex as soon as the table has data that are result of a join, or if sorting on several columns is combined, but that would just be some more complex logic in the function that turns a TableSort string into a safe OrderBy clause.
Have a look at the oml and let me know if this sort of thing is what you are looking for.
Dorine
Just to add some color to this reply.
The main concern is security and that's why that warning appears. As long as you can come up with a solution that you are confident it's reliable the warning is no longer a concern. Another thing to have in mind is that we probably will need to have a trade-off here. My two cents on this is that the most reasonable one is to have a bit more code than usual as long as it is easily understandable to ease on maintenance and troubleshooting. I tend to avoid dynamic SQL clauses because of that.
Have the attributes listed mapped with an alias that will not be showed in runtime. The "Name" attribute could map with the "SortByName" alias and the OrderBy clause will only work for the attributes that are mapped, always falling back to a default one chosen at design time. The trade-off is that whenever there's a need to change attributes this code will also need to be changed. Also, the warning will still appear but you are now certain that your code is secure.