mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
support throttle like calls as partial calls
This commit is contained in:
@@ -1379,6 +1379,48 @@ module PartialInvokeNode {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A partial call that behaves like a throttle call, like `require("call-limit")(fs, limit)` or `_.memoize`.
|
||||
* Seen as a partial invocation that binds no arguments.
|
||||
*/
|
||||
private class ThrottleLikePartialCall extends PartialInvokeNode::Range, DataFlow::CallNode {
|
||||
int callbackIndex;
|
||||
|
||||
ThrottleLikePartialCall() {
|
||||
callbackIndex = 0 and
|
||||
(
|
||||
this = LodashUnderscore::member(["throttle", "debounce", "once", "memoize"]).getACall()
|
||||
or
|
||||
this =
|
||||
DataFlow::moduleImport(["call-limit", "lodash.debounce", "lodash.throttle", "debounce"])
|
||||
.getACall()
|
||||
)
|
||||
or
|
||||
callbackIndex = 1 and
|
||||
(
|
||||
this = LodashUnderscore::member(["after", "before"]).getACall()
|
||||
or
|
||||
// not jQuery: https://github.com/cowboy/jquery-throttle-debounce
|
||||
this = DataFlow::globalVarRef("$").getAMemberCall(["throttle", "debounce"])
|
||||
)
|
||||
or
|
||||
callbackIndex = -1 and
|
||||
this = DataFlow::moduleMember("throttle-debounce", ["debounce", "throttle"]).getACall()
|
||||
}
|
||||
|
||||
override DataFlow::SourceNode getBoundFunction(DataFlow::Node callback, int boundArgs) {
|
||||
(
|
||||
callbackIndex >= 0 and
|
||||
callback = getArgument(callbackIndex)
|
||||
or
|
||||
callbackIndex = -1 and
|
||||
callback = getLastArgument()
|
||||
) and
|
||||
boundArgs = 0 and
|
||||
result = this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A partial call through `ramda.partial`.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user