You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose we have a rule R1 to detect the call GCMBlockCipher.newInstance, and it has a depending detection rule R2 on its parameter to detect the call AESEngine.newInstance.
When R1 makes a finding, this code gets ultimately executed to handle depending detection rules (where expression is the argument, so here AESEngine.newInstance()):
However, because AESEngine.newInstance() is here a MethodInvocationTree, it will execute the first case and try to resolveValuesInOuterScope, without handling depending rules.
Note that if our code uses a intermediary variable engine instead (like below), this problem does not occur and depending rules are correctly handled.
A trivial solution idea would be to just handle depending rules in any case, so removing the last line from the else statement, giving the following code:
if (expressioninstanceofMethodInvocationTreemethodInvocationTree) {
// methods are part of the outer scoperesolveValuesInOuterScope(methodInvocationTree, parameter);
} elseif (expressioninstanceofNewClassTreenewClassTree
&& assignedSymbol.isEmpty()) {
// follow expression directly, do not find matching expression in the method// scopedetectionStore.onDetectedDependingParameter(
parameter, newClassTree, DetectionStore.Scope.EXPRESSION);
}
// handle next rulesdetectionStore.onDetectedDependingParameter(
parameter, expressionTree, DetectionStore.Scope.ENCLOSED_METHOD);
However, while this easy fix correctly fixes our example above, it breaks 3 JCA unit tests (for reasons I have not investigated).
The text was updated successfully, but these errors were encountered:
The problem
Let's consider this code line example:
Suppose we have a rule R1 to detect the call
GCMBlockCipher.newInstance
, and it has a depending detection rule R2 on its parameter to detect the callAESEngine.newInstance
.When R1 makes a finding, this code gets ultimately executed to handle depending detection rules (where
expression
is the argument, so hereAESEngine.newInstance()
):However, because
AESEngine.newInstance()
is here aMethodInvocationTree
, it will execute the first case and try toresolveValuesInOuterScope
, without handling depending rules.Note that if our code uses a intermediary variable
engine
instead (like below), this problem does not occur and depending rules are correctly handled.Solution?
A trivial solution idea would be to just handle depending rules in any case, so removing the last line from the
else
statement, giving the following code:However, while this easy fix correctly fixes our example above, it breaks 3 JCA unit tests (for reasons I have not investigated).
The text was updated successfully, but these errors were encountered: