mirror of
https://github.com/github/codeql.git
synced 2025-12-21 11:16:30 +01:00
Merge pull request #15550 from yoff/python/remove-pointsto-from-module-getAnExport
python: remove a use of points-to
This commit is contained in:
@@ -1,4 +1,16 @@
|
|||||||
import python
|
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.
|
* 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
|
or
|
||||||
exists(Module m | m = this.getEnclosingScope() and m.isPublic() |
|
exists(Module m | m = this.getEnclosingScope() and m.isPublic() |
|
||||||
/* If the module has an __all__, is this in it */
|
/* If the module has an __all__, is this in it */
|
||||||
not exists(m.getAnExport())
|
not exists(getAModuleExport(m))
|
||||||
or
|
or
|
||||||
m.getAnExport() = this.getName()
|
getAModuleExport(m) = this.getName()
|
||||||
)
|
)
|
||||||
or
|
or
|
||||||
exists(Class c | c = this.getEnclosingScope() |
|
exists(Class c | c = this.getEnclosingScope() |
|
||||||
|
|||||||
Reference in New Issue
Block a user