mirror of
https://github.com/github/codeql.git
synced 2026-03-30 20:28:15 +02:00
Merge pull request #21429 from github/tausbn/fix-bad-join-in-method-call-order
Python: Fix bad join in method call order computation
This commit is contained in:
@@ -152,11 +152,7 @@ predicate missingCallToSuperclassMethod(Class base, Function shouldCall, string
|
||||
*/
|
||||
predicate missingCallToSuperclassMethodRestricted(Class base, Function shouldCall, string name) {
|
||||
missingCallToSuperclassMethod(base, shouldCall, name) and
|
||||
not exists(Class superBase |
|
||||
// Alert only on the highest base class that has the issue
|
||||
superBase = getADirectSuperclass+(base) and
|
||||
missingCallToSuperclassMethod(superBase, shouldCall, name)
|
||||
) and
|
||||
not superclassAlsoMissesCall(base, shouldCall, name) and
|
||||
not exists(Function subShouldCall |
|
||||
// Mention in the alert only the lowest method we're missing the call to
|
||||
subShouldCall.getScope() = getADirectSubclass+(shouldCall.getScope()) and
|
||||
@@ -164,6 +160,15 @@ predicate missingCallToSuperclassMethodRestricted(Class base, Function shouldCal
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if a strict superclass of `base` is also missing a call to `shouldCall` named `name`,
|
||||
* indicating that `base` is not the highest class in the hierarchy with this issue.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
private predicate superclassAlsoMissesCall(Class base, Function shouldCall, string name) {
|
||||
missingCallToSuperclassMethod(getADirectSuperclass+(base), shouldCall, name)
|
||||
}
|
||||
|
||||
/**
|
||||
* If `base` contains a `super()` call, gets a method in the inheritance hierarchy of `name` in the MRO of `base`
|
||||
* that does not contain a `super()` call, but would call `shouldCall` if it did, which does not otherwise get called
|
||||
|
||||
Reference in New Issue
Block a user