Modify CURD rule to support regex for SECURITY_ENFORCE clause
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user