Modify CURD rule to support regex for SECURITY_ENFORCE clause

This commit is contained in:
Joshua Arquilevich
2020-02-20 15:31:19 -08:00
parent df16093562
commit 8b94463074
2 changed files with 16 additions and 1 deletions

View File

@ -339,7 +339,8 @@ public class ApexCRUDViolationRule extends AbstractApexRule {
private boolean isWithSecurityEnforced(final AbstractApexNode<?> node){
if(node instanceof ASTSoqlExpression){
return ((ASTSoqlExpression) node).getQuery().contains("WITH SECURITY_ENFORCED");
String pattern = ".*\\bWITH SECURITY_ENFORCED\\b.*";
return ((ASTSoqlExpression) node).getQuery().matches(pattern);
}
return false;
}

View File

@ -287,6 +287,20 @@ public class Foo {
} ]]></code>
</test-code>
<test-code>
<description>Accepts Closure SECURITY ENFORCED 3 </description>
<expected-problems>1</expected-problems>
<code><![CDATA[
public class Foo {
public Contact foo(String tempID) {
Contact c = [SELECT Name FROM Contact WHERE Id=: tempID WItH SECURITY_ENFORCED];
return c;
}
} ]]></code>
</test-code>
<test-code>
<description>Proper accessibility CRUD,FLS </description>
<expected-problems>0</expected-problems>