Skip to content

Commit f59d15c

Browse files
committed
support when-guards
1 parent 8b0d578 commit f59d15c

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • ruby/ql/lib/codeql/ruby/controlflow/internal

ruby/ql/lib/codeql/ruby/controlflow/internal/Guards.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,13 @@ predicate guardControlsBlock(CfgNodes::AstCfgNode guard, BasicBlock bb, boolean
1111
s.getValue() = branch and
1212
conditionBlock.edgeDominates(bb, s)
1313
)
14+
or
15+
exists(BasicBlock whenBlock, ConditionalSuccessor s, ControlFlowNode guardNode, int i |
16+
guardNode.isAfter(guard.(CfgNodes::ExprNodes::WhenClauseCfgNode).getAstNode()) and
17+
whenBlock.getNode(i) = guardNode and
18+
i != 0 and
19+
guardNode = any(ControlFlowNode n).getASuccessor(s) and
20+
s.getValue() = branch and
21+
whenBlock.dominates(bb)
22+
)
1423
}

0 commit comments

Comments
 (0)