Skip to content

Commit d5a06ad

Browse files
committed
Ruby: revert trackUseNode to idiomatic type-tracking
The optimizations done here now seem to backfire and cause more problems than they fix.
1 parent b364860 commit d5a06ad

File tree

1 file changed

+3
-34
lines changed

1 file changed

+3
-34
lines changed

ruby/ql/lib/codeql/ruby/ApiGraphs.qll

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -580,23 +580,6 @@ module API {
580580
/** Gets a node reachable from a use-node. */
581581
private DataFlow::LocalSourceNode useCandFwd() { result = useCandFwd(TypeTracker::end()) }
582582

583-
private DataFlow::Node useCandRev(TypeBackTracker tb) {
584-
result = useCandFwd() and
585-
tb.start()
586-
or
587-
exists(TypeBackTracker tb2, DataFlow::LocalSourceNode mid, TypeTracker t |
588-
mid = useCandRev(tb2) and
589-
result = mid.backtrack(tb2, tb) and
590-
pragma[only_bind_out](result) = useCandFwd(t) and
591-
pragma[only_bind_out](t) = pragma[only_bind_out](tb).getACompatibleTypeTracker()
592-
)
593-
}
594-
595-
private DataFlow::LocalSourceNode useCandRev() {
596-
result = useCandRev(TypeBackTracker::end()) and
597-
isUse(result)
598-
}
599-
600583
private predicate isDef(DataFlow::Node rhs) {
601584
// If a call node is relevant as a use-node, treat its arguments as def-nodes
602585
argumentStep(_, useCandFwd(), rhs)
@@ -651,26 +634,12 @@ module API {
651634
*
652635
* The flow from `src` to the returned node may be inter-procedural.
653636
*/
654-
private DataFlow::Node trackUseNode(DataFlow::LocalSourceNode src, TypeTracker t) {
637+
private DataFlow::LocalSourceNode trackUseNode(DataFlow::LocalSourceNode src, TypeTracker t) {
655638
result = src and
656-
result = useCandRev() and
639+
isUse(src) and
657640
t.start()
658641
or
659-
exists(TypeTracker t2, DataFlow::LocalSourceNode mid |
660-
mid = trackUseNode(src, t2) and
661-
result = useNodeStep(mid, t2, t)
662-
)
663-
}
664-
665-
pragma[nomagic]
666-
private DataFlow::Node useNodeStep(
667-
DataFlow::LocalSourceNode mid, TypeTracker tmid, TypeTracker t
668-
) {
669-
exists(TypeBackTracker tb |
670-
result = mid.track(tmid, t) and
671-
pragma[only_bind_into](result) = useCandRev(pragma[only_bind_into](tb)) and
672-
pragma[only_bind_out](t) = pragma[only_bind_into](tb).getACompatibleTypeTracker()
673-
)
642+
exists(TypeTracker t2 | result = trackUseNode(src, t2).track(t2, t))
674643
}
675644

676645
/**

0 commit comments

Comments
 (0)