diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java
index de7c12562f..a4466f030a 100644
--- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java
+++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java
@@ -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;
}
diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/security/xml/ApexCRUDViolation.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/security/xml/ApexCRUDViolation.xml
index e57ed234b1..da4942da00 100644
--- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/security/xml/ApexCRUDViolation.xml
+++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/security/xml/ApexCRUDViolation.xml
@@ -287,6 +287,20 @@ public class Foo {
} ]]>
+
+ Accepts Closure SECURITY ENFORCED 3
+ 1
+
+
+
+
+
Proper accessibility CRUD,FLS
0