mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
JS: use inheritance in js/mixed-static-instance-this-access
This commit is contained in:
@@ -10,15 +10,19 @@
|
||||
*/
|
||||
import javascript
|
||||
|
||||
/** Holds if `base` declares or inherits method `m` with the given `name`. */
|
||||
predicate hasMethod(ClassDefinition base, string name, MethodDefinition m) {
|
||||
m = base.getMethod(name) or
|
||||
hasMethod(base.getSuperClassDefinition(), name, m)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `access` is in`fromMethod`, and it references `toMethod` through `this`.
|
||||
*/
|
||||
predicate isLocalMethodAccess(PropAccess access, MethodDefinition fromMethod, MethodDefinition toMethod) {
|
||||
fromMethod.getDeclaringClass() = toMethod.getDeclaringClass() and
|
||||
hasMethod(fromMethod.getDeclaringClass(), access.getPropertyName(), toMethod) and
|
||||
access.getEnclosingFunction() = fromMethod.getBody() and
|
||||
access.getBase() instanceof ThisExpr and
|
||||
access.getPropertyName() = toMethod.getName()
|
||||
access.getBase() instanceof ThisExpr
|
||||
}
|
||||
|
||||
string getKind(MethodDefinition m) {
|
||||
|
||||
@@ -216,6 +216,13 @@ class ClassDefinition extends @classdefinition, ClassOrInterface, AST::ValueNode
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the definition of the super class of this class, if it can be determined.
|
||||
*/
|
||||
ClassDefinition getSuperClassDefinition() {
|
||||
result = getSuperClass().analyze().getAValue().(AbstractClass).getClass()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user