Merge pull request #15550 from yoff/python/remove-pointsto-from-module-getAnExport

python: remove a use of points-to
This commit is contained in:
yoff
2024-02-20 19:04:46 +01:00
committed by GitHub

View File

@@ -1,4 +1,16 @@
import python
private import semmle.python.dataflow.new.internal.ImportResolution
/**
* Gets a name exported by module `m`, that is the names that will be added to a namespace by 'from this-module import *'.
*
* This aims to be the same as m.getAnExport(), but without using the points-to machinery.
*/
private string getAModuleExport(Module m) {
py_exports(m, result)
or
ImportResolution::module_export(m, result, _)
}
/**
* A Scope. A scope is the lexical extent over which all identifiers with the same name refer to the same variable.
@@ -74,9 +86,9 @@ class Scope extends Scope_ {
or
exists(Module m | m = this.getEnclosingScope() and m.isPublic() |
/* If the module has an __all__, is this in it */
not exists(m.getAnExport())
not exists(getAModuleExport(m))
or
m.getAnExport() = this.getName()
getAModuleExport(m) = this.getName()
)
or
exists(Class c | c = this.getEnclosingScope() |