I have a lookup table where the user will be able to filter the results using a filter like:
- Field [Name], Value [John], Delete Rule
- Field [Last Name], Value [Blake], Delete Rule
- [Has children] field, value [Yes], Delete rule
- Add Rule
Thus, the user will be able to set an arbitrary set of filters, which ultimately leads to a fully dynamic WHERE clause. In the future, I will also have to implement more complex logical expressions, such as
Where (first name = John OR first name = Nick) AND (last name = Blake or last name = Born),
Of all 10 fields that the user can or cannot filter, I do not know how many and which filters the user will set. Therefore, I cannot use a prepared statement (which assumes that at least we know the fields in the WHERE clause). That is why ready-made statements, unfortunately, are out of the question, I have to do this with the help of a simple old, generated SQL.
What measures can I take to protect my application from SQL Injection (REGEX-wise or any other way)?
source share