Skip to content

Commit f0dfa51

Browse files
committed
Dynamically determine the callback argument's position
An additional parameter may be anywhere in the parameter list and shift around the exact index of the callback argument in the parameter list. So, "dynamically" determine the index by type-checking a parameter in the parameter list. Note 1: There may be multiple matches since we're using `_` (don't care) as the argument index. Note 2: We could have used DataFlow::InvokeNode.getCallback if the supertype were not CallExpr, but jumping to data flow node is an overkill here.
1 parent 06e3a01 commit f0dfa51

File tree

1 file changed

+3
-1
lines changed
  • javascript/ql/lib/semmle/javascript

1 file changed

+3
-1
lines changed

javascript/ql/lib/semmle/javascript/AMD.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
9191
Function getFactoryFunction() { TValueNode(result) = this.getFactoryNodeInternal() }
9292

9393
private EarlyStageNode getFactoryNodeInternal() {
94-
result = TValueNode(this.getArgument(1))
94+
exists(Function factoryFunction | factoryFunction = this.getArgument(_) |
95+
result = TValueNode(factoryFunction)
96+
)
9597
or
9698
DataFlow::localFlowStep(result, this.getFactoryNodeInternal())
9799
}

0 commit comments

Comments
 (0)