i am creating a postgreSQL database reader which also includes a method for a user to type their own query. i want to protect the database by checking if the typed query contains any modifying code. this is my check:
private bool chech_unwanted_text(string query)
{
if (query.Contains("DELETE") || query.Contains("delete") || query.Contains("CREATE") ||
query.Contains("create") || query.Contains("COPY") || query.Contains("copy") ||
query.Contains("INSERT") || query.Contains("insert") || query.Contains("DROP") ||
query.Contains("drop") || query.Contains("UPDATE") || query.Contains("update") ||
query.Contains("ALTER") || query.Contains("alter"))
{
return false;
}
else return true;
}
is this the right method to check for a edit-safe query or is there an other, more reliable way to achieve this?
i know about granting rights to users but that is not working because i don't have a super-user account.