Skip to content

Commit 7d86b53

Browse files
committed
Python: Fix unwanted module type tracking
1 parent 76e5b59 commit 7d86b53

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

python/ql/src/experimental/dataflow/internal/DataFlowUtil.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Node importModule(string name) {
7070
// Because named imports are modelled as `AttrRead`s, the statement `from foo import bar as baz`
7171
// is interpreted as if it was an assignment `baz = foo.bar`, which means `baz` gets tracked as a
7272
// reference to `foo.bar`, as desired.
73-
result.asCfgNode().getNode() = any(ImportExpr i | i.getAnImportedModuleName() = name)
73+
result.asCfgNode().getNode() = any(ImportExpr i | i.getName() = name)
7474
}
7575

7676
/**

python/ql/test/experimental/dataflow/typetracking/moduleattr.expected

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
module_tracker
22
| import_as_attr.py:1:6:1:11 | ControlFlowNode for ImportExpr |
3-
| import_as_attr_dotted.py:0:0:0:0 | ModuleVariableNode for Global Variable attr_ref in Module import_as_attr_dotted |
4-
| import_as_attr_dotted.py:1:8:1:18 | ControlFlowNode for ImportExpr |
5-
| import_as_attr_dotted.py:1:23:1:30 | GSSA Variable attr_ref |
6-
| import_as_attr_dotted.py:3:1:3:1 | GSSA Variable x |
7-
| import_as_attr_dotted.py:3:5:3:12 | ControlFlowNode for attr_ref |
8-
| import_as_attr_dotted.py:6:5:6:5 | SSA variable y |
9-
| import_as_attr_dotted.py:6:9:6:16 | ControlFlowNode for attr_ref |
103
module_attr_tracker
114
| import_as_attr.py:0:0:0:0 | ModuleVariableNode for Global Variable attr_ref in Module import_as_attr |
125
| import_as_attr.py:1:20:1:35 | ControlFlowNode for ImportMember |

0 commit comments

Comments
 (0)