Skip to content

Negation of an if condition in CodeQL #10569

Answered by yoff
Sim4n6 asked this question in Q&A
Discussion options

You must be logged in to vote

tl;dr: Do like here

Hi, you have the right approach, defining a sanitiser is what will help you here. However, I think you want to write it in the form of a barrier guard, since sanitation depends on the results of eee.is_awesome or eee.is_cool. Only if such a method returns true do you want to consider eee safe.

The way to achieve this is in two steps. First you write a predicate identifying those method calls and then you feed that predicate to the BarrierGuard module. This requires the first predicate to be of a specific form:

private predicate checksEee(DataFlow::GuardNode g, ControlFlowNode eee, boolean branch) {
  exists(DataFlow::MethodCallNode mc |
    g = mc.asCfgNode() and
    mc.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Sim4n6
Comment options

Answer selected by Sim4n6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants