I'm building this method which allows to build SearchParameters
object. One of methods allows to specify Filter
field of this object. It looks like this (simplified version)
public SearchParameters CreateWithFilter(string fieldName, string operator, string value)
{
var filterString = $"{fieldName} {operator} '{value}'";
return new SearchParameters{ Filter = filterString };
}
so I can use it like this
var searchParameters = this.CreateWithFilter("manufacturer", "eq", "volvo");
Now, the issue is that this code is sql-injection-like vulnerable. If I'll call
var searchParameters = this.CreateWithFilter("manufacturer", "eq", "volvo' or someField eq 1 or manufacturer eq 'volvo");
I'll become a great Azure Search Hacker ;)
My question:
Are there any specific techniques within Azure Search similar to ones known from SQL world that would allow me to secure code against those types of injections?