Skip to content

Commit 518bfa4

Browse files
committed
move getAnInstanceMemberAccess to ClassNode
1 parent e8afafc commit 518bfa4

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

javascript/ql/src/semmle/javascript/dataflow/Nodes.qll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,31 @@ class ClassNode extends DataFlow::SourceNode {
10071007
result = getAnInstanceReference(DataFlow::TypeTracker::end())
10081008
}
10091009

1010+
/**
1011+
* Gets a property read that accesses the property `name` on an instance of this class.
1012+
*
1013+
* Concretely, this holds when the base is an instance of this class or a subclass thereof.
1014+
*/
1015+
pragma[nomagic]
1016+
DataFlow::PropRead getAnInstanceMemberAccess(string name, DataFlow::TypeTracker t) {
1017+
result = this.getAnInstanceReference(t.continue()).getAPropertyRead(name)
1018+
or
1019+
exists(DataFlow::ClassNode subclass |
1020+
result = subclass.getAnInstanceMemberAccess(name, t) and
1021+
not exists(subclass.getInstanceMember(name, _)) and
1022+
this = subclass.getADirectSuperClass()
1023+
)
1024+
}
1025+
1026+
/**
1027+
* Gets a property read that accesses the property `name` on an instance of this class.
1028+
*
1029+
* Concretely, this holds when the base is an instance of this class or a subclass thereof.
1030+
*/
1031+
DataFlow::PropRead getAnInstanceMemberAccess(string name) {
1032+
result = this.getAnInstanceMemberAccess(name, DataFlow::TypeTracker::end())
1033+
}
1034+
10101035
/**
10111036
* Gets an access to a static member of this class.
10121037
*/

javascript/ql/src/semmle/javascript/dataflow/internal/CallGraphs.qll

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module CallGraph {
5757
exists(DataFlow::ClassNode cls |
5858
exists(string name |
5959
function = cls.getInstanceMethod(name) and
60-
getAnInstanceMemberAccess(cls, name, t.continue()).flowsTo(result)
60+
cls.getAnInstanceMemberAccess(name, t.continue()).flowsTo(result)
6161
or
6262
function = cls.getStaticMethod(name) and
6363
cls.getAClassReference(t.continue()).getAPropertyRead(name).flowsTo(result)
@@ -133,26 +133,6 @@ module CallGraph {
133133
)
134134
}
135135

136-
/**
137-
* Gets a property read that accesses the property `name` on an instance of this class.
138-
*
139-
* Concretely, this holds when the base is an instance of this class or a subclass thereof.
140-
*
141-
* This predicate may be overridden to customize the class hierarchy analysis.
142-
*/
143-
pragma[nomagic]
144-
private DataFlow::PropRead getAnInstanceMemberAccess(
145-
DataFlow::ClassNode cls, string name, DataFlow::TypeTracker t
146-
) {
147-
result = cls.getAnInstanceReference(t.continue()).getAPropertyRead(name)
148-
or
149-
exists(DataFlow::ClassNode subclass |
150-
result = getAnInstanceMemberAccess(subclass, name, t) and
151-
not exists(subclass.getInstanceMember(name, _)) and
152-
cls = subclass.getADirectSuperClass()
153-
)
154-
}
155-
156136
/**
157137
* Gets a possible callee of `node` with the given `imprecision`.
158138
*

0 commit comments

Comments
 (0)