-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Python: Inconsistent behaviour of the getAMember and getMember predicates #19297
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
Comments
The query looks sensible at first sight. You say you'd like to find Have you checked that |
Hi @aibaars , Thanks for the quick reply! I can also confirm that retrieving all subclasses of Django
correctly returns |
You're right. You might want to use the following method, although I expect it to have the same problem as your query because it has the same code as what you wrote. codeql/python/ql/lib/semmle/python/frameworks/Django.qll Lines 790 to 797 in 6176202
|
This is the approach I started with, but it didn't work. After some troubleshooting, I was able to narrow down the issue to Just as a sanity check, I ran the following query again, and can confirm it still does not work:
|
I think this is an instance of an internal issue we're tracking (https://github.com/github/codeql-team/issues/3836), since the import happens from inside 'core'. |
@yoff since this is an internal issue, I am unable to access it, would you mind sharing more details? I ran some experiments on my side, and codeQL is sometimes able to flag the pattern I am describing even if the import happens from inside a package called 'core'. |
Sorry, I did not realize that, I am used to working "in the open". The issue description is this: For a module m located inside A.B.C, we compute the "name to use when importing m" as A.B.C.m. So it is "relative imports from inside a sub-package" that will likely fail. |
Thanks for the explanation. Even though I can feel like this is related to what I'm observing, this explanation unfortunately doesn't fit my issue perfectly. I will detail below my experiment to show you what I mean - all test cases below are done on the
I then run the following query:
Result: This doesn't work and the query shows no result
and run the same query as above. Result: This works, and the statement is correctly flagged The module This therefore goes against the description you provided as both modules are located on the same folder level, and yet, when imported from the same location, codeQL doesn't process them equally. |
Trying to access all nodes that represent an attribute of a Django subclass does not work as expected in https://github.com/HumanSignal/label-studio.
I am trying to detect a call to
AsyncMigrationStatus.objects
in the following block of code (https://github.com/HumanSignal/label-studio/blob/develop/label_studio/core/management/commands/show_async_migrations.py#L19):Using the following query:
AsyncMigrationStatus
is defined below (https://github.com/HumanSignal/label-studio/blob/develop/label_studio/core/models.py#L10):This query returns many results across the codebase but does not flag this specific statement, along with others.
I've tried many different approaches to understand the root cause of the issue without success. Please let me know if I am somehow misusing getAMember.
Below are my specs:
The text was updated successfully, but these errors were encountered: