Skip to content

Commit c8a7624

Browse files
committed
Python: Take __all__ into consideration for re-export of from <pkg> import *
However, we can see that `from <pkg> import *` and `import pkg` are handled differently. Would have liked `has_defined_all_indirection` to behave in the same way no matter how the import was made.
1 parent be5812c commit c8a7624

File tree

3 files changed

+6
-135
lines changed

3 files changed

+6
-135
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/ImportResolution.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ module ImportResolution {
9595
)
9696
or
9797
// `from <pkg> import *`
98-
module_export(ImportStar::getStarImported+(m), name, defn)
98+
exists(Module importedFrom |
99+
importedFrom = ImportStar::getStarImported(m) and
100+
module_export(importedFrom, name, defn) and
101+
potential_module_export(importedFrom, name)
102+
)
99103
or
100104
// `import <pkg>` or `from <pkg> import <stuff>`
101105
exists(Alias a |

0 commit comments

Comments
 (0)