mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
move getAnInstanceMemberAccess to ClassNode
This commit is contained in:
@@ -1007,6 +1007,31 @@ class ClassNode extends DataFlow::SourceNode {
|
||||
result = getAnInstanceReference(DataFlow::TypeTracker::end())
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a property read that accesses the property `name` on an instance of this class.
|
||||
*
|
||||
* Concretely, this holds when the base is an instance of this class or a subclass thereof.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
DataFlow::PropRead getAnInstanceMemberAccess(string name, DataFlow::TypeTracker t) {
|
||||
result = this.getAnInstanceReference(t.continue()).getAPropertyRead(name)
|
||||
or
|
||||
exists(DataFlow::ClassNode subclass |
|
||||
result = subclass.getAnInstanceMemberAccess(name, t) and
|
||||
not exists(subclass.getInstanceMember(name, _)) and
|
||||
this = subclass.getADirectSuperClass()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a property read that accesses the property `name` on an instance of this class.
|
||||
*
|
||||
* Concretely, this holds when the base is an instance of this class or a subclass thereof.
|
||||
*/
|
||||
DataFlow::PropRead getAnInstanceMemberAccess(string name) {
|
||||
result = this.getAnInstanceMemberAccess(name, DataFlow::TypeTracker::end())
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an access to a static member of this class.
|
||||
*/
|
||||
|
||||
@@ -57,7 +57,7 @@ module CallGraph {
|
||||
exists(DataFlow::ClassNode cls |
|
||||
exists(string name |
|
||||
function = cls.getInstanceMethod(name) and
|
||||
getAnInstanceMemberAccess(cls, name, t.continue()).flowsTo(result)
|
||||
cls.getAnInstanceMemberAccess(name, t.continue()).flowsTo(result)
|
||||
or
|
||||
function = cls.getStaticMethod(name) and
|
||||
cls.getAClassReference(t.continue()).getAPropertyRead(name).flowsTo(result)
|
||||
@@ -133,26 +133,6 @@ module CallGraph {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a property read that accesses the property `name` on an instance of this class.
|
||||
*
|
||||
* Concretely, this holds when the base is an instance of this class or a subclass thereof.
|
||||
*
|
||||
* This predicate may be overridden to customize the class hierarchy analysis.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
private DataFlow::PropRead getAnInstanceMemberAccess(
|
||||
DataFlow::ClassNode cls, string name, DataFlow::TypeTracker t
|
||||
) {
|
||||
result = cls.getAnInstanceReference(t.continue()).getAPropertyRead(name)
|
||||
or
|
||||
exists(DataFlow::ClassNode subclass |
|
||||
result = getAnInstanceMemberAccess(subclass, name, t) and
|
||||
not exists(subclass.getInstanceMember(name, _)) and
|
||||
cls = subclass.getADirectSuperClass()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a possible callee of `node` with the given `imprecision`.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user