зеркало из https://github.com/github/codeql.git
JS: support FP pattern for js/unbound-event-handler-receiver
This commit is contained in:
Родитель
9c41b214ee
Коммит
b35c4b2a9a
|
@ -18,7 +18,15 @@ private predicate isBoundInMethod(MethodDeclaration method) {
|
|||
bindingMethod.getDeclaringClass() = method.getDeclaringClass() and
|
||||
not bindingMethod.isStatic() and
|
||||
thiz.getBinder().getAstNode() = bindingMethod.getBody()
|
||||
|
|
||||
|
|
||||
exists (DataFlow::MethodCallNode bind, DataFlow::PropWrite w |
|
||||
// this[x] = <expr>.bind(...)
|
||||
w = thiz.getAPropertyWrite() and
|
||||
not exists(w.getPropertyName()) and
|
||||
bind.getMethodName() = "bind" and
|
||||
bind.flowsTo(w.getRhs())
|
||||
)
|
||||
or
|
||||
// require("auto-bind")(this)
|
||||
thiz.flowsTo(DataFlow::moduleImport("auto-bind").getACall().getArgument(0))
|
||||
or
|
||||
|
|
|
@ -134,4 +134,25 @@ class Component2 extends React.Component {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class Component3 extends React.Component {
|
||||
|
||||
render() {
|
||||
return <div>
|
||||
<div onClick={this.bound_throughIterator}/> // OK
|
||||
</div>
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Object.getOwnPropertyNames( Component3.prototype )
|
||||
.filter( prop => typeof this[ prop ] === 'function' )
|
||||
.forEach( prop => ( this[ prop ] = this[ prop ].bind( this ) ) );
|
||||
}
|
||||
|
||||
bound_throughIterator() {
|
||||
this.setState({ });
|
||||
}
|
||||
}
|
||||
|
||||
// semmle-extractor-options: --experimental
|
||||
|
|
Загрузка…
Ссылка в новой задаче