Skip to content

Commit 2c463cb

Browse files
committed
Ruby: prune more aggressively
1 parent bd3c6d5 commit 2c463cb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

ruby/ql/lib/codeql/ruby/typetracking/TypeTrackerSpecific.qll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,11 @@ private predicate hasWithContentSummary(
451451
* Holds if the given component can't be evaluated by `evaluateSummaryComponentStackLocal`.
452452
*/
453453
pragma[nomagic]
454-
predicate isNonLocal(SummaryComponent component) { component = SC::content(_) }
454+
predicate isNonLocal(SummaryComponent component) {
455+
component = SC::content(_)
456+
or
457+
component = SC::withContent(_)
458+
}
455459

456460
/**
457461
* Gets a data flow node corresponding an argument or return value of `call`,
@@ -495,6 +499,14 @@ private predicate dependsOnSummaryComponentStackCons(
495499
dependsOnSummaryComponentStack(callable, SCS::push(head, tail))
496500
}
497501

502+
pragma[nomagic]
503+
private predicate dependsOnSummaryComponentStackConsLocal(
504+
SummarizedCallable callable, SummaryComponent head, SummaryComponentStack tail
505+
) {
506+
dependsOnSummaryComponentStackCons(callable, head, tail) and
507+
not isNonLocal(head)
508+
}
509+
498510
pragma[nomagic]
499511
private predicate dependsOnSummaryComponentStackLeaf(
500512
SummarizedCallable callable, SummaryComponent leaf
@@ -515,7 +527,7 @@ private DataFlow::Node evaluateSummaryComponentStackLocal(
515527
or
516528
exists(DataFlow::Node prev, SummaryComponent head, SummaryComponentStack tail |
517529
prev = evaluateSummaryComponentStackLocal(callable, call, tail) and
518-
dependsOnSummaryComponentStackCons(callable, pragma[only_bind_into](head),
530+
dependsOnSummaryComponentStackConsLocal(callable, pragma[only_bind_into](head),
519531
pragma[only_bind_out](tail)) and
520532
stack = SCS::push(pragma[only_bind_out](head), pragma[only_bind_out](tail))
521533
|

0 commit comments

Comments
 (0)