Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit adaf323

Browse files
committed
JS: IteratorExceptionStep
1 parent 7021be0 commit adaf323

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

javascript/ql/src/semmle/javascript/StandardLibrary.qll

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,13 @@ private class ArrayIterationCallbackAsPartialInvoke extends DataFlow::PartialInv
7474
* A flow step propagating the exception thrown from a callback to a method whose name coincides
7575
* a built-in Array iteration method, such as `forEach` or `map`.
7676
*/
77-
private class IteratorExceptionStep extends DataFlow::MethodCallNode, DataFlow::AdditionalFlowStep {
78-
IteratorExceptionStep() {
79-
exists(string name | name = getMethodName() |
80-
name = "forEach" or
81-
name = "each" or
82-
name = "map" or
83-
name = "filter" or
84-
name = "some" or
85-
name = "every" or
86-
name = "fold" or
87-
name = "reduce"
88-
)
89-
}
90-
77+
private class IteratorExceptionStep extends DataFlow::SharedFlowStep {
9178
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
92-
pred = getAnArgument().(DataFlow::FunctionNode).getExceptionalReturn() and
93-
succ = this.getExceptionalReturn()
79+
exists(DataFlow::MethodCallNode call |
80+
call.getMethodName() = ["forEach", "each", "map", "filter", "some", "every", "fold", "reduce"] and
81+
pred = call.getAnArgument().(DataFlow::FunctionNode).getExceptionalReturn() and
82+
succ = call.getExceptionalReturn()
83+
)
9484
}
9585
}
9686

0 commit comments

Comments
 (0)