Python: Fix underlying problem of not using Alias

This commit is contained in:
Rasmus Wriedt Larsen
2023-10-20 11:13:48 +02:00
parent a956e1f613
commit f1fd9b4c7a
3 changed files with 13 additions and 10 deletions

View File

@@ -163,12 +163,13 @@ module NotExposed {
newOrExistingModeling(spec).getASubclass*().getAValueReachableFromSource().asExpr() and
importMember.getScope() = mod and
loc = importMember.getLocation() and
(
mod.isPackageInit() and
newAliasFullyQualified = mod.getPackageName() + "." + importMember.getName()
exists(Alias alias, string base |
mod.isPackageInit() and base = mod.getPackageName()
or
not mod.isPackageInit() and
newAliasFullyQualified = mod.getName() + "." + importMember.getName()
not mod.isPackageInit() and base = mod.getName()
|
alias.getValue() = importMember and
newAliasFullyQualified = base + "." + alias.getAsname()
) and
(
not hasAllStatement(mod)

View File

@@ -1,4 +1,5 @@
| Django.Views.View~Subclass | find_subclass_test | Member[View] |
| Django.Views.View~Subclass | find_subclass_test | Member[clash2] |
| Django.Views.View~Subclass | find_subclass_test | Member[clash3] |
| Django.Views.View~Subclass | find_subclass_test | Member[clash] |
| flask.MethodView~Subclass | find_subclass_test | Member[C] |
| flask.View~Subclass | find_subclass_test | Member[A] |
@@ -7,6 +8,7 @@
| flask.View~Subclass | find_subclass_test | Member[ViewAliasInTry] |
| flask.View~Subclass | find_subclass_test | Member[ViewAlias] |
| flask.View~Subclass | find_subclass_test | Member[View] |
| flask.View~Subclass | find_subclass_test | Member[clash2] |
| flask.View~Subclass | find_subclass_test | Member[clash3] |
| flask.View~Subclass | find_subclass_test | Member[clash] |
| flask.View~Subclass | find_subclass_test | Member[complete_module_alias] |

View File

@@ -21,18 +21,18 @@ except:
if cond:
from flask.views import View as clash
else:
from django.views.generic import View as clash # $ SPURIOUS: View=Django.Views.View~Subclass
from django.views.generic import View as clash
if cond:
from flask.views import View as clash2 # $ MISSING
from flask.views import View as clash2
else:
from django.views.generic import View as clash2 # $ MISSING
from django.views.generic import View as clash2
print(clash2)
if cond:
from flask.views import View as clash3
else:
from django.views.generic import View as clash3 # $ MISSING
from django.views.generic import View as clash3
print(clash3)
import flask.views as containing_module_alias # $ MISSING