Skip to content

Python: Modernize 4 queries for missing/multiple calls to init/del methods #19932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
271f32e
Move missing/multiple calls to init/del queries to folder
joefarebrother Jun 30, 2025
a2fc14a
Update missing call to init
joefarebrother Jun 30, 2025
6f9983a
Add missing call to del
joefarebrother Jun 30, 2025
adcfdf1
Modernize multple calls to init/del
joefarebrother Jul 1, 2025
caddec4
Update alert messages
joefarebrother Jul 1, 2025
71d1179
Fix FPs and typo
joefarebrother Jul 1, 2025
085df26
Move tests and add inline expectation postprocessing
joefarebrother Jul 2, 2025
2faf67d
Update test outputs + fix semantics
joefarebrother Jul 2, 2025
1b4e2fe
Change implenetation of missing calls to use getASuperCallTarget, and…
joefarebrother Jul 3, 2025
16b90a1
Fixes
joefarebrother Jul 3, 2025
b3056fc
Update tests for calls to init + fixes
joefarebrother Jul 3, 2025
73057d3
Add additional test case + update missing del tests
joefarebrother Jul 3, 2025
2e6f35b
Remove case excluding classes with a __new__ method; as it doesn't ma…
joefarebrother Jul 3, 2025
c5b79fa
Update multiple calls queries to include call targets in alert message
joefarebrother Jul 4, 2025
804b9ef
Update tests and add an additional test
joefarebrother Jul 4, 2025
6ca4f32
qhelp: move examples to subfolder
joefarebrother Jul 4, 2025
2e5f470
Update qhelp + alert messages
joefarebrother Jul 4, 2025
d2c68de
Update integration test output
joefarebrother Jul 4, 2025
f1026e4
Add change note
joefarebrother Jul 4, 2025
c47e6e3
Add qldoc
joefarebrother Jul 4, 2025
4b49ac3
Fix changenote formatting
joefarebrother Jul 4, 2025
d163bdf
Fix typos
joefarebrother Jul 4, 2025
e8a65b8
Update integration test outout and fix qhelp
joefarebrother Jul 7, 2025
f5066c7
Remove tostring
joefarebrother Jul 7, 2025
2c93e2c
Inline locationBefore
joefarebrother Jul 14, 2025
7dad89f
Adress review suggestions - cleanups
joefarebrother Jul 14, 2025
d2a8e5d
Fix typo in example
joefarebrother Jul 18, 2025
b33a1c2
Fix doc typo
joefarebrother Jul 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix typos
  • Loading branch information
joefarebrother committed Jul 4, 2025
commit d163bdf981b6956c7953d9bb66ef5be47cc67ffd
19 changes: 10 additions & 9 deletions python/ql/src/Classes/CallsToInitDel/MethodCallOrder.qll
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)
}

/** Gets the method called by `meth` named `name` with `call`, with `mroBase` as the type determining the MRO to search. */
/** Gets the method called by `meth` named `name` with `call`, with `mroBase` as the type determining the MRO to search. */
Function getDirectSuperCallTargetFromCall(
Class mroBase, Function meth, DataFlow::MethodCallNode call, string name
) {
Expand All @@ -54,7 +54,7 @@
)
}

/** Gets a method that is transitively called by a call to `cls.<name>`, with `mroBase` as the type determining the MRO to search. */
/** Gets a method that is transitively called by a call to `cls.<name>`, with `mroBase` as the type determining the MRO to search. */
Function getASuperCallTargetFromClass(Class mroBase, Class cls, string name) {
exists(Function target |
target = findFunctionAccordingToMroKnownStartingClass(cls, mroBase, name) and
Expand All @@ -79,7 +79,7 @@
exists(meth.getANormalExit()) // doesn't always raise an exception
}

/** Holds if `call` is a call to `super().<name>`. No distinction is made btween 0- and 2- arg super calls. */
/** Holds if `call` is a call to `super().<name>`. No distinction is made between 0- and 2- arg super calls. */
predicate superCall(DataFlow::MethodCallNode call, string name) {
exists(DataFlow::Node sup |
call.calls(sup, name) and
Expand Down Expand Up @@ -113,7 +113,7 @@
call.calls(callTarget, name) and
self.getParameter() = meth.getArg(0) and
self.(DataFlow::LocalSourceNode).flowsTo(call.getArg(0)) and
not exists(Class target | callTarget = classTracker(target))
)
}

Expand All @@ -127,8 +127,9 @@
not callsMethodOnUnknownClassWithSelf(getASuperCallTargetFromClass(base, base, name), name)
}

/** Holds if `base` does not call a superclass method `shouldCall` named `name` when it appears it should.
* Results are restricted to hold only for the highest `base` class and the lowest `shouldCall` method in the heirarchy for which this applies.
/**
* Holds if `base` does not call a superclass method `shouldCall` named `name` when it appears it should.
* Results are restricted to hold only for the highest `base` class and the lowest `shouldCall` method in the hierarchy for which this applies.
*/
predicate missingCallToSuperclassMethodRestricted(Class base, Function shouldCall, string name) {
missingCallToSuperclassMethod(base, shouldCall, name) and
Expand All @@ -144,11 +145,11 @@
)
}

/**
* If `base` contains a `super()` call, gets a method in the inheritence heirarchy of `name` in the MRO of `base`
/**
* 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
* during a call to `base.<name>`.
* */
* during a call to `base.<name>`.
*/
Function getPossibleMissingSuper(Class base, Function shouldCall, string name) {
missingCallToSuperclassMethod(base, shouldCall, name) and
exists(Function baseMethod |
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy