I know that SOQL injection can be used to query data the user shouldn't see by providing a value like Bob \' OR Name LIKE '%'
. But I'm wondering if you could use an input value like Name LIKE '%')'; delete [SELECT Id FROM Contact]; //
to delete all contacts from an org. Is something like this possible, or does Apex prevent this?
Example below. I tried running this, but am getting the error mismatched character '<EOF>' expecting '''
@AuraEnabled
// whereClause value: Name LIKE '%')'; delete [SELECT Id FROM Contact]; //
public static void soqlInjectionTest(String whereClause) {
String queryString = 'SELECT Id FROM Contact WHERE ' + whereClause;
List<Contact> contacts = Database.query(queryString);
}