I'm just not finding any answers I like out there.
I would like to do something like:
public class TestSqlInjectionController : ApiController
{
public IEnumerable<TestSqlInjectionUser> Get([ValidateSqlInjection]string usernameFilter = null)
{
where [ValidateSqlInjection]
looks for basics like throwing an error if the incoming filter contains ;
, --
, DROP
, or DELETE
.
So I'd have a maintainable list.
Then create a custom attribute:
[FilterField1ValidateSqlInjection]
Here maybe split a comma-delimited list into an array.
Then roll through the array and make sure each element matches one of the values in an enum.
Does this sound like it's heading in the right direction?
The problem is that we have to use dynamic SQL for a lot of paging, sorting and filtering. There is no way around it.
So command parameters don't really do a whole lot for us.
Does the custom property attributes sound like a good idea to anyone out there with .Net SQL Injection experience?