mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Python: Add import * test
This test shows off a few things: - transitive chains of `import *` - multiple modules exporting the same name (to test for cross-talk)
This commit is contained in:
2
python/ql/test/experimental/dataflow/import-star/deux.py
Normal file
2
python/ql/test/experimental/dataflow/import-star/deux.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from trois import *
|
||||
print(foo)
|
||||
@@ -0,0 +1,3 @@
|
||||
moduleVariables
|
||||
reads
|
||||
writes
|
||||
12
python/ql/test/experimental/dataflow/import-star/global.ql
Normal file
12
python/ql/test/experimental/dataflow/import-star/global.ql
Normal file
@@ -0,0 +1,12 @@
|
||||
import python
|
||||
import semmle.python.dataflow.new.DataFlow
|
||||
|
||||
query DataFlow::Node moduleVariables() { result instanceof DataFlow::ModuleVariableNode }
|
||||
|
||||
query predicate reads(DataFlow::Node fromNode, DataFlow::Node toNode) {
|
||||
fromNode.(DataFlow::ModuleVariableNode).getARead() = toNode
|
||||
}
|
||||
|
||||
query predicate writes(DataFlow::Node fromNode, DataFlow::Node toNode) {
|
||||
fromNode = toNode.(DataFlow::ModuleVariableNode).getAWrite()
|
||||
}
|
||||
1
python/ql/test/experimental/dataflow/import-star/one.py
Normal file
1
python/ql/test/experimental/dataflow/import-star/one.py
Normal file
@@ -0,0 +1 @@
|
||||
from two import *
|
||||
@@ -0,0 +1,2 @@
|
||||
from one import *
|
||||
print(foo)
|
||||
@@ -0,0 +1,2 @@
|
||||
from un import *
|
||||
print(foo)
|
||||
@@ -0,0 +1 @@
|
||||
foo = 5
|
||||
@@ -0,0 +1 @@
|
||||
foo = 5
|
||||
2
python/ql/test/experimental/dataflow/import-star/two.py
Normal file
2
python/ql/test/experimental/dataflow/import-star/two.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from three import *
|
||||
print(foo)
|
||||
1
python/ql/test/experimental/dataflow/import-star/un.py
Normal file
1
python/ql/test/experimental/dataflow/import-star/un.py
Normal file
@@ -0,0 +1 @@
|
||||
from deux import *
|
||||
Reference in New Issue
Block a user