Skip to content

Commit 0c5b528

Browse files
committed
Address review comments
1 parent bf3fb68 commit 0c5b528

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/SummaryTypeTracker.qll

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ signature module Input {
7373
}
7474

7575
// Relating nodes to summaries
76-
/** Gets a dataflow node respresenting the argument of `call` indicated by `arg`. */
77-
Node argumentOf(Node call, SummaryComponent arg, boolean isOutput);
76+
/**
77+
* Gets a dataflow node respresenting the argument of `call` indicated by `arg`.
78+
*
79+
* Returns the post-update node of the argument when `isPostUpdate` is true.
80+
*/
81+
Node argumentOf(Node call, SummaryComponent arg, boolean isPostUpdate);
7882

7983
/** Gets a dataflow node respresenting the parameter of `callable` indicated by `param`. */
8084
Node parameterOf(Node callable, SummaryComponent param);
@@ -221,7 +225,8 @@ module SummaryFlow<Input I> implements Output<I> {
221225

222226
/**
223227
* Gets a data flow `I::Node` corresponding an argument or return value of `call`,
224-
* as specified by `component`.
228+
* as specified by `component`. `isOutput` indicates whether the node represents
229+
* an output node or an input node.
225230
*/
226231
bindingset[call, component]
227232
private I::Node evaluateSummaryComponentLocal(
@@ -300,10 +305,16 @@ module SummaryFlow<Input I> implements Output<I> {
300305
pragma[only_bind_out](tail)) and
301306
stack = I::push(pragma[only_bind_out](head), pragma[only_bind_out](tail))
302307
|
308+
// `Parameter[X]` is only allowed in the output of flow summaries (hence `isOutput = true`),
309+
// however the target of the parameter (e.g. `Argument[Y].Parameter[X]`) should be fetched
310+
// not from a post-update argument node (hence `isOutput0 = false`)
303311
result = I::parameterOf(prev, head) and
304312
isOutput0 = false and
305313
isOutput = true
306314
or
315+
// `ReturnValue` is only allowed in the input of flow summaries (hence `isOutput = false`),
316+
// and the target of the return value (e.g. `Argument[X].ReturnValue`) should be fetched not
317+
// from a post-update argument node (hence `isOutput0 = false`)
307318
result = I::returnOf(prev, head) and
308319
isOutput0 = false and
309320
isOutput = false

ruby/ql/lib/codeql/ruby/typetracking/internal/SummaryTypeTracker.qll

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ signature module Input {
7373
}
7474

7575
// Relating nodes to summaries
76-
/** Gets a dataflow node respresenting the argument of `call` indicated by `arg`. */
77-
Node argumentOf(Node call, SummaryComponent arg, boolean isOutput);
76+
/**
77+
* Gets a dataflow node respresenting the argument of `call` indicated by `arg`.
78+
*
79+
* Returns the post-update node of the argument when `isPostUpdate` is true.
80+
*/
81+
Node argumentOf(Node call, SummaryComponent arg, boolean isPostUpdate);
7882

7983
/** Gets a dataflow node respresenting the parameter of `callable` indicated by `param`. */
8084
Node parameterOf(Node callable, SummaryComponent param);
@@ -221,7 +225,8 @@ module SummaryFlow<Input I> implements Output<I> {
221225

222226
/**
223227
* Gets a data flow `I::Node` corresponding an argument or return value of `call`,
224-
* as specified by `component`.
228+
* as specified by `component`. `isOutput` indicates whether the node represents
229+
* an output node or an input node.
225230
*/
226231
bindingset[call, component]
227232
private I::Node evaluateSummaryComponentLocal(
@@ -300,10 +305,16 @@ module SummaryFlow<Input I> implements Output<I> {
300305
pragma[only_bind_out](tail)) and
301306
stack = I::push(pragma[only_bind_out](head), pragma[only_bind_out](tail))
302307
|
308+
// `Parameter[X]` is only allowed in the output of flow summaries (hence `isOutput = true`),
309+
// however the target of the parameter (e.g. `Argument[Y].Parameter[X]`) should be fetched
310+
// not from a post-update argument node (hence `isOutput0 = false`)
303311
result = I::parameterOf(prev, head) and
304312
isOutput0 = false and
305313
isOutput = true
306314
or
315+
// `ReturnValue` is only allowed in the input of flow summaries (hence `isOutput = false`),
316+
// and the target of the return value (e.g. `Argument[X].ReturnValue`) should be fetched not
317+
// from a post-update argument node (hence `isOutput0 = false`)
307318
result = I::returnOf(prev, head) and
308319
isOutput0 = false and
309320
isOutput = false

0 commit comments

Comments
 (0)