Skip to content

Commit 6eea906

Browse files
committed
Data flow: Synthesize post-update nodes for callback arguments inside summarized callables
1 parent 8356991 commit 6eea906

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ module Private {
301301
TWithoutContentSummaryComponent(ContentSet c) or
302302
TWithContentSummaryComponent(ContentSet c)
303303

304-
private TParameterSummaryComponent thisParam() {
305-
result = TParameterSummaryComponent(instanceParameterPosition())
304+
private TParameterSummaryComponent callbackSelfParam() {
305+
result = TParameterSummaryComponent(callbackSelfParameterPosition())
306306
}
307307

308308
newtype TSummaryComponentStack =
@@ -311,7 +311,7 @@ module Private {
311311
any(RequiredSummaryComponentStack x).required(head, tail)
312312
or
313313
any(RequiredSummaryComponentStack x).required(TParameterSummaryComponent(_), tail) and
314-
head = thisParam()
314+
head = callbackSelfParam()
315315
or
316316
derivedFluentFlowPush(_, _, _, head, tail, _)
317317
}
@@ -336,7 +336,7 @@ module Private {
336336
callbackRef = s.drop(_) and
337337
(isCallbackParameter(callbackRef) or callbackRef.head() = TReturnSummaryComponent(_)) and
338338
input = callbackRef.tail() and
339-
output = TConsSummaryComponentStack(thisParam(), input) and
339+
output = TConsSummaryComponentStack(callbackSelfParam(), input) and
340340
preservesValue = true
341341
)
342342
or
@@ -439,6 +439,9 @@ module Private {
439439
out.head() = TParameterSummaryComponent(_) and
440440
s = out.tail()
441441
)
442+
or
443+
// Add the post-update node corresponding to the requested argument node
444+
outputState(c, s) and isCallbackParameter(s)
442445
}
443446

444447
private newtype TSummaryNodeState =

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class SummarizedCallableBase = string;
1515

1616
DataFlowCallable inject(SummarizedCallable c) { result.asLibraryCallable() = c }
1717

18-
/** Gets the parameter position of the instance parameter. */
19-
ArgumentPosition instanceParameterPosition() { none() } // disables implicit summary flow to `self` for callbacks
18+
/** Gets the parameter position representing a callback itself, if any. */
19+
ArgumentPosition callbackSelfParameterPosition() { none() } // disables implicit summary flow to `self` for callbacks
2020

2121
/** Gets the synthesized summary data-flow node for the given values. */
2222
Node summaryNode(SummarizedCallable c, SummaryNodeState state) { result = TSummaryNode(c, state) }

0 commit comments

Comments
 (0)