From c82690f4c16f3d34b8d03f7227ccdecc15c47f1b Mon Sep 17 00:00:00 2001 From: Asger F Date: Tue, 15 Jan 2019 13:14:10 +0000 Subject: [PATCH] JS: address comments --- .../src/semmle/javascript/dataflow/Nodes.qll | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/javascript/ql/src/semmle/javascript/dataflow/Nodes.qll b/javascript/ql/src/semmle/javascript/dataflow/Nodes.qll index 3ff3c73f96e..6418b5f490c 100644 --- a/javascript/ql/src/semmle/javascript/dataflow/Nodes.qll +++ b/javascript/ql/src/semmle/javascript/dataflow/Nodes.qll @@ -488,6 +488,8 @@ DataFlow::SourceNode moduleMember(string path, string m) { * method: function() {} * }); * ``` + * + * Additional patterns can be recognized as class nodes, by extending `DataFlow::ClassNode::Range`. */ class ClassNode extends DataFlow::SourceNode { ClassNode::Range impl; @@ -510,24 +512,28 @@ class ClassNode extends DataFlow::SourceNode { FunctionNode getConstructor() { result = impl.getConstructor() } /** - * Gets an instance method with the given name, if any. + * Gets an instance method declared in this class, with the given name, if any. + * + * Does not include methods from superclasses. */ FunctionNode getInstanceMethod(string name) { result = impl.getInstanceMethod(name) } /** - * Gets an instance method of this class. + * Gets an instance method declared in this class. * * The constructor is not considered an instance method. + * + * Does not include methods from superclasses. */ FunctionNode getAnInstanceMethod() { result = impl.getAnInstanceMethod() } /** - * Gets the static method of this class with the given name. + * Gets the static method declared in this class with the given name. */ FunctionNode getStaticMethod(string name) { result = impl.getStaticMethod(name) } /** - * Gets a static method of this class. + * Gets a static method declared in this class. * * The constructor is not considered a static method. */ @@ -619,12 +625,12 @@ module ClassNode { result = method.getBody().flow() ) or - result = getAPropertyWrite(name).getRhs().getALocalSource() + result = getAPropertySource(name) } override FunctionNode getAStaticMethod() { exists(MethodDeclaration method | - method = astNode.(ClassDefinition).getAMethod() and + method = astNode.getAMethod() and method.isStatic() and result = method.getBody().flow() ) @@ -646,7 +652,7 @@ module ClassNode { override FunctionNode getConstructor() { result = this } override FunctionNode getInstanceMethod(string name) { - result = getAPrototypeReference().getAPropertyWrite(name).getRhs().getALocalSource() + result = getAPrototypeReference().getAPropertySource(name) } override FunctionNode getAnInstanceMethod() { @@ -654,7 +660,7 @@ module ClassNode { } override FunctionNode getStaticMethod(string name) { - result = getAPropertyWrite(name).getRhs().getALocalSource() + result = getAPropertySource(name) } override FunctionNode getAStaticMethod() {