mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Python: Add import regression for refined variable
This commit is contained in:
@@ -11,6 +11,9 @@ private class SourceString extends DataFlow::Node {
|
||||
SourceString() {
|
||||
this.asExpr().(StrConst).getText() = contents and
|
||||
this.asExpr().getParent() instanceof Assign
|
||||
or
|
||||
this.asExpr().(ClassExpr).getInnerScope().getName() = "SOURCE" and
|
||||
contents = "SOURCE"
|
||||
}
|
||||
|
||||
string getContents() { result = contents }
|
||||
|
||||
@@ -93,6 +93,10 @@ check("subpackage2_attr", subpackage2_attr, "subpackage2_attr", globals()) #$ pr
|
||||
from if_then_else import if_then_else_defined
|
||||
check("if_then_else_defined", if_then_else_defined, "if_defined", globals()) #$ prints=if_defined prints=else_defined_1 prints=else_defined_2
|
||||
|
||||
# check that refined definitions are handled correctly
|
||||
import refined # $ imports=refined as=refined
|
||||
check("refined.SOURCE", refined.SOURCE, refined.SOURCE, globals()) #$ MISSING: prints=SOURCE
|
||||
|
||||
exit(__file__)
|
||||
|
||||
print()
|
||||
|
||||
12
python/ql/test/experimental/import-resolution/refined.py
Normal file
12
python/ql/test/experimental/import-resolution/refined.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from trace import *
|
||||
enter(__file__)
|
||||
|
||||
class SOURCE(object): pass
|
||||
|
||||
check("SOURCE", SOURCE, SOURCE, globals()) #$ prints=SOURCE
|
||||
|
||||
SOURCE.foo = 42
|
||||
|
||||
check("SOURCE", SOURCE, SOURCE, globals()) #$ prints=SOURCE
|
||||
|
||||
exit(__file__)
|
||||
Reference in New Issue
Block a user