Integers won't count as SOQL injection
This commit is contained in:
@ -96,6 +96,10 @@ public class ApexSOQLInjectionRule extends AbstractApexRule {
|
||||
if (literal != null) {
|
||||
if (left != null) {
|
||||
Object o = literal.getNode().getLiteral();
|
||||
if (o instanceof Integer || o instanceof Boolean || o instanceof Double) {
|
||||
safeVariables.add(Helper.getFQVariableName(left));
|
||||
}
|
||||
|
||||
if (o instanceof String) {
|
||||
if (SELECT_PATTERN.matcher((String) o).matches()) {
|
||||
selectContainingVariables.put(Helper.getFQVariableName(left), Boolean.TRUE);
|
||||
|
@ -206,4 +206,19 @@ public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>Dynamic SOQL with Integer
|
||||
</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public void test1() {
|
||||
Integer field1 = 4;
|
||||
Database.query('SELECT Id FROM Account LIMIT ' + field1);
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
</test-data>
|
||||
|
Reference in New Issue
Block a user