JS: Add: dataflow step for find, findLast, findLastIndex callback functions

This commit is contained in:
Napalys
2024-11-19 09:42:11 +01:00
parent b64b837db3
commit c03d69af1e
4 changed files with 23 additions and 3 deletions

View File

@@ -483,4 +483,18 @@ private module ArrayLibraries {
)
}
}
/**
* Defines a data flow step that tracks the flow of data through callback functions in arrays.
*/
private class ArrayCallBackDataFlowStep extends PreCallGraphStep {
override predicate loadStep(DataFlow::Node obj, DataFlow::Node element, string prop) {
exists(DataFlow::MethodCallNode call |
call.getMethodName() = ["findLast", "find", "findLastIndex"] and
prop = arrayLikeElement() and
obj = call.getReceiver() and
element = call.getCallback(0).getParameter(0)
)
}
}
}