Skip to content

Commit 96711b2

Browse files
committed
Ruby: improve join order in trackInstanceRec
1 parent 6e7aea8 commit 96711b2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowDispatch.qll

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,10 @@ private predicate localFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo,
579579
summary.toString() = "level"
580580
}
581581

582+
private predicate hasAdjacentTypeCheckedReads(DataFlow::Node node) {
583+
hasAdjacentTypeCheckedReads(_, _, node.asExpr(), _)
584+
}
585+
582586
/**
583587
* We exclude steps into `self` parameters and type checked variables. For those,
584588
* we instead rely on the type of the enclosing module resp. the type being checked
@@ -588,12 +592,12 @@ private predicate localFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo,
588592
pragma[nomagic]
589593
private DataFlow::Node trackInstanceRec(Module tp, TypeTracker t, boolean exact, StepSummary summary) {
590594
exists(DataFlow::Node mid | mid = trackInstance(tp, exact, t) |
591-
StepSummary::smallstep(mid, result, summary)
595+
StepSummary::smallstep(mid, result, summary) and
596+
not result instanceof SelfParameterNode
592597
or
593-
localFlowStep(mid, result, summary)
594-
) and
595-
not result instanceof SelfParameterNode and
596-
not hasAdjacentTypeCheckedReads(_, _, result.asExpr(), _)
598+
localFlowStep(mid, result, summary) and
599+
not hasAdjacentTypeCheckedReads(result)
600+
)
597601
}
598602

599603
pragma[nomagic]

0 commit comments

Comments
 (0)