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
The controls predicate in GuardCondition fails to detect a control flow influence from a nested if. In the following example the influence from condition to call() is only revealed in the first if, but not in the second.
#include<exception>voidcall()
{
}
voidmy_fn(bool outer, bool condition)
{
if (condition) // detected
{
throwstd::exception();
}
if (outer)
{
if (condition) // not detected
{
throwstd::exception();
}
}
call();
}
I think you may be misunderstanding what GuardCondition.support means. From its doc:
The predicate holds if all paths to controlled go via the testIsTrue edge of the control-flow graph.
(emphasis on "all" is mine)
This is not the case for the nested condition, as there is a path going through outer == false that avoids the nested if altogether. Similarly, neither outer == false nor outer == true control the basic block of call(), as they both have a path going to call() through them (so neither have exclusivity on the paths to call()). As a consequence, the only GuardCondition controlling the basic block of call() is indeed the one you found, via the false value.
Incidentally, from the snippet you posted and the presence of the line in your query, I'm assuming you are running codeql in the CLI. I think that for playing around with CodeQL the best might be to use VSCode with the CodeQL extension. Apart from powerful debugging tools like quick evaluation, when running queries the results are clickable allowing to highlight the result in the extracted code.
Incidentally, from the snippet you posted and the presence of the line in your query, I'm assuming you are running codeql in the CLI. I think that for playing around with CodeQL the best might be to use VSCode with the CodeQL extension. Apart from powerful debugging tools like quick evaluation, when running queries the results are clickable allowing to highlight the result in the extracted code.
Obviously disregard this comment if you just ran on the CLI to paste the result here 😅
The
controls
predicate inGuardCondition
fails to detect a control flow influence from a nestedif
. In the following example the influence fromcondition
tocall()
is only revealed in the firstif
, but not in the second.Query I tried:
Output I received:
I expected to also see an influence from line 17, but none is being found.
CodeQL version: 2.19.3
The text was updated successfully, but these errors were encountered: