Skip to content

Commit d3ee5f6

Browse files
authored
Merge pull request #15550 from yoff/python/remove-pointsto-from-module-getAnExport
python: remove a use of points-to
2 parents 2da0098 + 22e72d2 commit d3ee5f6

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

python/ql/lib/semmle/python/Scope.qll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
import python
2+
private import semmle.python.dataflow.new.internal.ImportResolution
3+
4+
/**
5+
* Gets a name exported by module `m`, that is the names that will be added to a namespace by 'from this-module import *'.
6+
*
7+
* This aims to be the same as m.getAnExport(), but without using the points-to machinery.
8+
*/
9+
private string getAModuleExport(Module m) {
10+
py_exports(m, result)
11+
or
12+
ImportResolution::module_export(m, result, _)
13+
}
214

315
/**
416
* 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_ {
7486
or
7587
exists(Module m | m = this.getEnclosingScope() and m.isPublic() |
7688
/* If the module has an __all__, is this in it */
77-
not exists(m.getAnExport())
89+
not exists(getAModuleExport(m))
7890
or
79-
m.getAnExport() = this.getName()
91+
getAModuleExport(m) = this.getName()
8092
)
8193
or
8294
exists(Class c | c = this.getEnclosingScope() |

0 commit comments

Comments
 (0)