Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce DEX-450 Exam - Topic 11 Question 133 Discussion

A developer is tasked to perform a security review of the ContactSearch Apex class that exists in the system. Within the class, the developer identifies the following method as a security threat:ist performSearch (String lastName} [return Database.query('SELECT Id, FirstName, LastName FROM Contact WHERE LastName Likes'+lastName+'s'")?;What are two ways the developer can update the method to prevent a SOQL injection attack?Choose 2 answers
C) Use the Readonly annotation and the with sharing keyword on the class. and D) Use a regular expression on the parameter to remove special characters.
A) Use variable binding and replace the dynamic query with a static SOQL.
B) Use the sacapeSingleQuotes method to sanitize the parameter before its use.

Salesforce DEX-450 Exam - Topic 11 Question 133 Discussion

Actual exam question for Salesforce's DEX-450 exam
Question #: 133
Topic #: 11
[All DEX-450 Questions]

A developer is tasked to perform a security review of the ContactSearch Apex class that exists in the system. Within the class, the developer identifies the following method as a security threat:

ist performSearch (String lastName} [

return Database.query('SELECT Id, FirstName, LastName FROM Contact WHERE LastName Like

s'+lastName+'s'")?;

What are two ways the developer can update the method to prevent a SOQL injection attack?

Choose 2 answers

Show Suggested Answer Hide Answer
Suggested Answer: C, D

Contribute your Thoughts:

0/2000 characters
Stephaine
3 days ago
A) and B) are the best options to prevent SOQL injection!
upvoted 0 times
...
Lynna
8 days ago
I recall the importance of using the with sharing keyword, but I don't think it directly prevents SOQL injection like the other options do.
upvoted 0 times
...
Kattie
13 days ago
I feel like we practiced a similar question where we had to sanitize inputs. I think option D could be useful, but it might not be as effective as binding.
upvoted 0 times
...
Ashleigh
18 days ago
I'm not entirely sure about option B. I think using escapeSingleQuotes could help, but I'm not confident it covers all cases.
upvoted 0 times
...
Socorro
23 days ago
I remember we discussed variable binding in class; I think option A is definitely a good choice to prevent SOQL injection.
upvoted 0 times
...

Save Cancel