mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
JS: Use getABoundFunctionValue in PostMessageEventHandler
This commit is contained in:
@@ -127,6 +127,8 @@ module DataFlow {
|
||||
* possibly derived from a partial function invocation.
|
||||
*/
|
||||
final FunctionNode getABoundFunctionValue(int boundArgs) {
|
||||
result = getAFunctionValue() and boundArgs = 0
|
||||
or
|
||||
CallGraph::getABoundFunctionReference(result, boundArgs).flowsTo(this)
|
||||
}
|
||||
|
||||
|
||||
@@ -174,18 +174,20 @@ private module PersistentWebStorage {
|
||||
* An event handler that handles `postMessage` events.
|
||||
*/
|
||||
class PostMessageEventHandler extends Function {
|
||||
int paramIndex;
|
||||
|
||||
PostMessageEventHandler() {
|
||||
exists(CallExpr addEventListener |
|
||||
addEventListener.getCallee().accessesGlobal("addEventListener") and
|
||||
exists(DataFlow::CallNode addEventListener |
|
||||
addEventListener = DataFlow::globalVarRef("addEventListener").getACall() and
|
||||
addEventListener.getArgument(0).mayHaveStringValue("message") and
|
||||
addEventListener.getArgument(1).analyze().getAValue().(AbstractFunction).getFunction() = this
|
||||
addEventListener.getArgument(1).getABoundFunctionValue(paramIndex).getFunction() = this
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameter that contains the event.
|
||||
*/
|
||||
SimpleParameter getEventParameter() { result = getParameter(0) }
|
||||
Parameter getEventParameter() { result = getParameter(paramIndex) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user