Skip to content

Commit 0d642e5

Browse files
committed
Limit wrapper call argument steps
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8390a2d1-70e3-4a01-84d3-3e5747d5da0b
1 parent ebcde45 commit 0d642e5

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

javascript/ql/lib/semmle/javascript/dataflow/internal/FunctionWrapperSteps.qll

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ private DataFlow::SourceNode forwardedCalleeSource(
155155
exists(DataFlow::TypeBackTracker t2 | result = forwardedCalleeSource(call, t2).backtrack(t2, t))
156156
}
157157

158-
/** Data flow into a concrete function invoked through a forwarding wrapper. */
158+
/**
159+
* Data flow into a concrete function invoked through a forwarding wrapper.
160+
*
161+
* Only arguments with a statically known position and a corresponding non-rest parameter are
162+
* modeled.
163+
*/
159164
private class FunctionWrapperCallStep extends DataFlow::SharedFlowStep {
160165
DataFlow::CallNode call;
161166
DataFlow::FunctionNode wrapped;
@@ -167,8 +172,11 @@ private class FunctionWrapperCallStep extends DataFlow::SharedFlowStep {
167172

168173
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
169174
exists(int index |
175+
// getArgument only has a result when the argument position is statically known.
170176
pred = call.getArgument(index) and
171-
succ = wrapped.getParameter(index)
177+
succ = wrapped.getParameter(index) and
178+
// A rest parameter receives an array, not the argument at this index.
179+
not succ.(DataFlow::ParameterNode).isRestParameter()
172180
)
173181
}
174182
}

0 commit comments

Comments
 (0)