Skip to content

Commit 3739072

Browse files
committed
Python: Fixed most problems from last commit
That one line was an afterthought, and certainly did not work as intended.
1 parent 97fefd2 commit 3739072

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/ImportResolution.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ module ImportResolution {
118118
EssaFlow::defToFirstUse(firstDef, mid) and
119119
EssaFlow::useToNextUse*(mid, end) and
120120
not EssaFlow::useToNextUse(end, _) and
121-
lastUseVar.getAUse() = end and
122121
val.asCfgNode() = end
123122
)
124123
)
Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +0,0 @@
1-
| pkg/alias_only_direct.py:1:26:1:36 | Comment # $ tracked | Missing result:tracked= |
2-
| pkg/alias_problem.py:1:26:1:36 | Comment # $ tracked | Missing result:tracked= |
3-
| pkg/alias_problem_fixed.py:3:26:3:36 | Comment # $ tracked | Missing result:tracked= |
4-
| pkg/problem_absolute_import.py:1:29:1:39 | Comment # $ tracked | Missing result:tracked= |
5-
| pkg/use.py:2:30:2:40 | Comment # $ tracked | Missing result:tracked= |
6-
| pkg/use.py:3:16:3:26 | Comment # $ tracked | Missing result:tracked= |
7-
| pkg/use.py:9:36:9:46 | Comment # $ tracked | Missing result:tracked= |
8-
| pkg/use.py:10:16:10:26 | Comment # $ tracked | Missing result:tracked= |
9-
| pkg/use.py:16:42:16:52 | Comment # $ tracked | Missing result:tracked= |
10-
| pkg/use.py:17:16:17:26 | Comment # $ tracked | Missing result:tracked= |
11-
| pkg/use.py:23:33:23:43 | Comment # $ tracked | Missing result:tracked= |
12-
| pkg/use.py:24:16:24:26 | Comment # $ tracked | Missing result:tracked= |
13-
| pkg/use.py:30:40:30:50 | Comment # $ tracked | Missing result:tracked= |
14-
| pkg/use.py:31:16:31:26 | Comment # $ tracked | Missing result:tracked= |
15-
| pkg/use.py:37:49:37:59 | Comment # $ tracked | Missing result:tracked= |
16-
| pkg/use.py:38:16:38:26 | Comment # $ tracked | Missing result:tracked= |
17-
| pkg/use.py:43:47:43:57 | Comment # $ tracked | Missing result:tracked= |
18-
| pkg/use.py:44:16:44:26 | Comment # $ tracked | Missing result:tracked= |
19-
| pkg/works_absolute_import.py:2:29:2:39 | Comment # $ tracked | Missing result:tracked= |

python/ql/test/experimental/import-resolution/ModuleExport.expected

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1+
| attr_clash.__init__ | __file__ | attr_clash/__init__.py:6:6:6:13 | ControlFlowNode for __file__ |
12
| attr_clash.__init__ | __name__ | attr_clash/__init__.py:0:0:0:0 | GSSA Variable __name__ |
23
| attr_clash.__init__ | __package__ | attr_clash/__init__.py:0:0:0:0 | GSSA Variable __package__ |
34
| attr_clash.__init__ | clashing_attr | attr_clash/__init__.py:4:1:4:13 | GSSA Variable clashing_attr |
45
| attr_clash.__init__ | enter | attr_clash/__init__.py:2:1:2:5 | ControlFlowNode for enter |
56
| attr_clash.__init__ | exit | attr_clash/__init__.py:6:1:6:4 | ControlFlowNode for exit |
7+
| attr_clash.clashing_attr | __file__ | attr_clash/clashing_attr.py:4:6:4:13 | ControlFlowNode for __file__ |
68
| attr_clash.clashing_attr | __name__ | attr_clash/clashing_attr.py:0:0:0:0 | GSSA Variable __name__ |
79
| attr_clash.clashing_attr | __package__ | attr_clash/clashing_attr.py:0:0:0:0 | GSSA Variable __package__ |
810
| attr_clash.clashing_attr | enter | attr_clash/clashing_attr.py:2:1:2:5 | ControlFlowNode for enter |
911
| attr_clash.clashing_attr | exit | attr_clash/clashing_attr.py:4:1:4:4 | ControlFlowNode for exit |
12+
| attr_clash.non_clashing_submodule | __file__ | attr_clash/non_clashing_submodule.py:4:6:4:13 | ControlFlowNode for __file__ |
1013
| attr_clash.non_clashing_submodule | __name__ | attr_clash/non_clashing_submodule.py:0:0:0:0 | GSSA Variable __name__ |
1114
| attr_clash.non_clashing_submodule | __package__ | attr_clash/non_clashing_submodule.py:0:0:0:0 | GSSA Variable __package__ |
1215
| attr_clash.non_clashing_submodule | enter | attr_clash/non_clashing_submodule.py:2:1:2:5 | ControlFlowNode for enter |
1316
| attr_clash.non_clashing_submodule | exit | attr_clash/non_clashing_submodule.py:4:1:4:4 | ControlFlowNode for exit |
17+
| bar | __file__ | bar.py:6:6:6:13 | ControlFlowNode for __file__ |
1418
| bar | __name__ | bar.py:0:0:0:0 | GSSA Variable __name__ |
1519
| bar | __package__ | bar.py:0:0:0:0 | GSSA Variable __package__ |
1620
| bar | bar_attr | bar.py:4:1:4:8 | GSSA Variable bar_attr |
1721
| bar | enter | bar.py:2:1:2:5 | ControlFlowNode for enter |
1822
| bar | exit | bar.py:6:1:6:4 | ControlFlowNode for exit |
23+
| baz | __file__ | baz.py:6:6:6:13 | ControlFlowNode for __file__ |
1924
| baz | __name__ | baz.py:0:0:0:0 | GSSA Variable __name__ |
2025
| baz | __package__ | baz.py:0:0:0:0 | GSSA Variable __package__ |
2126
| baz | baz_attr | baz.py:4:1:4:8 | GSSA Variable baz_attr |
2227
| baz | enter | baz.py:2:1:2:5 | ControlFlowNode for enter |
2328
| baz | exit | baz.py:6:1:6:4 | ControlFlowNode for exit |
2429
| block_flow_check | SOURCE | block_flow_check.py:12:25:12:30 | ControlFlowNode for SOURCE |
30+
| block_flow_check | __file__ | block_flow_check.py:14:6:14:13 | ControlFlowNode for __file__ |
2531
| block_flow_check | __name__ | block_flow_check.py:0:0:0:0 | GSSA Variable __name__ |
2632
| block_flow_check | __package__ | block_flow_check.py:0:0:0:0 | GSSA Variable __package__ |
2733
| block_flow_check | check | block_flow_check.py:12:1:12:5 | ControlFlowNode for check |
@@ -30,6 +36,7 @@
3036
| block_flow_check | globals | block_flow_check.py:12:33:12:39 | ControlFlowNode for globals |
3137
| block_flow_check | object | block_flow_check.py:4:14:4:19 | ControlFlowNode for object |
3238
| block_flow_check | staticmethod | block_flow_check.py:0:0:0:0 | GSSA Variable staticmethod |
39+
| foo | __file__ | foo.py:14:6:14:13 | ControlFlowNode for __file__ |
3340
| foo | __name__ | foo.py:0:0:0:0 | GSSA Variable __name__ |
3441
| foo | __package__ | foo.py:0:0:0:0 | GSSA Variable __package__ |
3542
| foo | __private_foo_attr | foo.py:8:1:8:18 | GSSA Variable __private_foo_attr |
@@ -41,23 +48,28 @@
4148
| foo | foo_attr | foo.py:5:1:5:8 | GSSA Variable foo_attr |
4249
| foo | globals | foo.py:12:71:12:77 | ControlFlowNode for globals |
4350
| has_defined_all | __all__ | has_defined_all.py:7:1:7:7 | GSSA Variable __all__ |
51+
| has_defined_all | __file__ | has_defined_all.py:9:6:9:13 | ControlFlowNode for __file__ |
4452
| has_defined_all | __name__ | has_defined_all.py:0:0:0:0 | GSSA Variable __name__ |
4553
| has_defined_all | __package__ | has_defined_all.py:0:0:0:0 | GSSA Variable __package__ |
4654
| has_defined_all | all_defined_bar | has_defined_all.py:5:1:5:15 | GSSA Variable all_defined_bar |
4755
| has_defined_all | all_defined_foo | has_defined_all.py:4:1:4:15 | GSSA Variable all_defined_foo |
4856
| has_defined_all | enter | has_defined_all.py:2:1:2:5 | ControlFlowNode for enter |
4957
| has_defined_all | exit | has_defined_all.py:9:1:9:4 | ControlFlowNode for exit |
5058
| has_defined_all_copy | __all__ | has_defined_all_copy.py:9:1:9:7 | GSSA Variable __all__ |
59+
| has_defined_all_copy | __file__ | has_defined_all_copy.py:11:6:11:13 | ControlFlowNode for __file__ |
5160
| has_defined_all_copy | __name__ | has_defined_all_copy.py:0:0:0:0 | GSSA Variable __name__ |
5261
| has_defined_all_copy | __package__ | has_defined_all_copy.py:0:0:0:0 | GSSA Variable __package__ |
5362
| has_defined_all_copy | all_defined_bar_copy | has_defined_all_copy.py:7:1:7:20 | GSSA Variable all_defined_bar_copy |
5463
| has_defined_all_copy | all_defined_foo_copy | has_defined_all_copy.py:6:1:6:20 | GSSA Variable all_defined_foo_copy |
5564
| has_defined_all_copy | enter | has_defined_all_copy.py:4:1:4:5 | ControlFlowNode for enter |
5665
| has_defined_all_copy | exit | has_defined_all_copy.py:11:1:11:4 | ControlFlowNode for exit |
66+
| has_defined_all_indirection | __file__ | has_defined_all_indirection.py:6:6:6:13 | ControlFlowNode for __file__ |
5767
| has_defined_all_indirection | __name__ | has_defined_all_indirection.py:0:0:0:0 | GSSA Variable __name__ |
5868
| has_defined_all_indirection | __package__ | has_defined_all_indirection.py:0:0:0:0 | GSSA Variable __package__ |
5969
| has_defined_all_indirection | all_defined_foo_copy | has_defined_all_copy.py:6:1:6:20 | GSSA Variable all_defined_foo_copy |
70+
| has_defined_all_indirection | enter | has_defined_all_indirection.py:2:1:2:5 | ControlFlowNode for enter |
6071
| has_defined_all_indirection | exit | has_defined_all_indirection.py:6:1:6:4 | ControlFlowNode for exit |
72+
| if_then_else | __file__ | if_then_else.py:16:6:16:13 | ControlFlowNode for __file__ |
6173
| if_then_else | __name__ | if_then_else.py:0:0:0:0 | GSSA Variable __name__ |
6274
| if_then_else | __package__ | if_then_else.py:0:0:0:0 | GSSA Variable __package__ |
6375
| if_then_else | enter | if_then_else.py:2:1:2:5 | ControlFlowNode for enter |
@@ -68,6 +80,7 @@
6880
| if_then_else | if_then_else_defined | if_then_else.py:14:9:14:28 | GSSA Variable if_then_else_defined |
6981
| if_then_else_refined | SOURCE | if_then_else_refined.py:11:11:11:16 | ControlFlowNode for SOURCE |
7082
| if_then_else_refined | SOURCE | if_then_else_refined.py:13:11:13:16 | ControlFlowNode for SOURCE |
83+
| if_then_else_refined | __file__ | if_then_else_refined.py:19:6:19:13 | ControlFlowNode for __file__ |
7184
| if_then_else_refined | __name__ | if_then_else_refined.py:0:0:0:0 | GSSA Variable __name__ |
7285
| if_then_else_refined | __package__ | if_then_else_refined.py:0:0:0:0 | GSSA Variable __package__ |
7386
| if_then_else_refined | check | if_then_else_refined.py:17:1:17:5 | ControlFlowNode for check |
@@ -76,22 +89,26 @@
7689
| if_then_else_refined | exit | if_then_else_refined.py:19:1:19:4 | ControlFlowNode for exit |
7790
| if_then_else_refined | globals | if_then_else_refined.py:17:24:17:30 | ControlFlowNode for globals |
7891
| if_then_else_refined | src | if_then_else_refined.py:17:19:17:21 | ControlFlowNode for src |
92+
| namespace_package.namespace_module | __file__ | namespace_package/namespace_module.py:6:6:6:13 | ControlFlowNode for __file__ |
7993
| namespace_package.namespace_module | __name__ | namespace_package/namespace_module.py:0:0:0:0 | GSSA Variable __name__ |
8094
| namespace_package.namespace_module | __package__ | namespace_package/namespace_module.py:0:0:0:0 | GSSA Variable __package__ |
8195
| namespace_package.namespace_module | enter | namespace_package/namespace_module.py:2:1:2:5 | ControlFlowNode for enter |
8296
| namespace_package.namespace_module | exit | namespace_package/namespace_module.py:6:1:6:4 | ControlFlowNode for exit |
8397
| namespace_package.namespace_module | namespace_module_attr | namespace_package/namespace_module.py:4:1:4:21 | GSSA Variable namespace_module_attr |
98+
| package.__init__ | __file__ | package/__init__.py:7:6:7:13 | ControlFlowNode for __file__ |
8499
| package.__init__ | __name__ | package/__init__.py:0:0:0:0 | GSSA Variable __name__ |
85100
| package.__init__ | __package__ | package/__init__.py:0:0:0:0 | GSSA Variable __package__ |
86101
| package.__init__ | attr_used_in_subpackage | package/__init__.py:4:1:4:23 | GSSA Variable attr_used_in_subpackage |
87102
| package.__init__ | enter | package/__init__.py:2:1:2:5 | ControlFlowNode for enter |
88103
| package.__init__ | exit | package/__init__.py:7:1:7:4 | ControlFlowNode for exit |
89104
| package.__init__ | package_attr | package/__init__.py:5:1:5:12 | GSSA Variable package_attr |
105+
| package.subpackage2.__init__ | __file__ | package/subpackage2/__init__.py:6:6:6:13 | ControlFlowNode for __file__ |
90106
| package.subpackage2.__init__ | __name__ | package/subpackage2/__init__.py:0:0:0:0 | GSSA Variable __name__ |
91107
| package.subpackage2.__init__ | __package__ | package/subpackage2/__init__.py:0:0:0:0 | GSSA Variable __package__ |
92108
| package.subpackage2.__init__ | enter | package/subpackage2/__init__.py:2:1:2:5 | ControlFlowNode for enter |
93109
| package.subpackage2.__init__ | exit | package/subpackage2/__init__.py:6:1:6:4 | ControlFlowNode for exit |
94110
| package.subpackage2.__init__ | subpackage2_attr | package/subpackage2/__init__.py:4:1:4:16 | GSSA Variable subpackage2_attr |
111+
| package.subpackage.__init__ | __file__ | package/subpackage/__init__.py:14:6:14:13 | ControlFlowNode for __file__ |
95112
| package.subpackage.__init__ | __name__ | package/subpackage/__init__.py:0:0:0:0 | GSSA Variable __name__ |
96113
| package.subpackage.__init__ | __package__ | package/subpackage/__init__.py:0:0:0:0 | GSSA Variable __package__ |
97114
| package.subpackage.__init__ | check | package/subpackage/__init__.py:12:1:12:5 | ControlFlowNode for check |
@@ -104,27 +121,32 @@
104121
| package.subpackage.__init__ | irrelevant_attr | package/subpackage/__init__.py:11:24:11:38 | GSSA Variable irrelevant_attr |
105122
| package.subpackage.__init__ | submodule | package/subpackage/__init__.py:12:35:12:43 | ControlFlowNode for submodule |
106123
| package.subpackage.__init__ | subpackage_attr | package/subpackage/__init__.py:4:1:4:15 | GSSA Variable subpackage_attr |
124+
| package.subpackage.submodule | __file__ | package/subpackage/submodule.py:7:6:7:13 | ControlFlowNode for __file__ |
107125
| package.subpackage.submodule | __name__ | package/subpackage/submodule.py:0:0:0:0 | GSSA Variable __name__ |
108126
| package.subpackage.submodule | __package__ | package/subpackage/submodule.py:0:0:0:0 | GSSA Variable __package__ |
109127
| package.subpackage.submodule | enter | package/subpackage/submodule.py:2:1:2:5 | ControlFlowNode for enter |
110128
| package.subpackage.submodule | exit | package/subpackage/submodule.py:7:1:7:4 | ControlFlowNode for exit |
111129
| package.subpackage.submodule | irrelevant_attr | package/subpackage/submodule.py:5:1:5:15 | GSSA Variable irrelevant_attr |
112130
| package.subpackage.submodule | submodule_attr | package/subpackage/submodule.py:4:1:4:14 | GSSA Variable submodule_attr |
113131
| refined | SOURCE | refined.py:12:25:12:30 | ControlFlowNode for SOURCE |
132+
| refined | __file__ | refined.py:14:6:14:13 | ControlFlowNode for __file__ |
114133
| refined | __name__ | refined.py:0:0:0:0 | GSSA Variable __name__ |
115134
| refined | __package__ | refined.py:0:0:0:0 | GSSA Variable __package__ |
116135
| refined | check | refined.py:12:1:12:5 | ControlFlowNode for check |
117136
| refined | enter | refined.py:2:1:2:5 | ControlFlowNode for enter |
118137
| refined | exit | refined.py:14:1:14:4 | ControlFlowNode for exit |
119138
| refined | globals | refined.py:12:33:12:39 | ControlFlowNode for globals |
120139
| refined | object | refined.py:4:14:4:19 | ControlFlowNode for object |
140+
| simplistic_reexport | __file__ | simplistic_reexport.py:19:6:19:13 | ControlFlowNode for __file__ |
121141
| simplistic_reexport | __name__ | simplistic_reexport.py:0:0:0:0 | GSSA Variable __name__ |
122142
| simplistic_reexport | __package__ | simplistic_reexport.py:0:0:0:0 | GSSA Variable __package__ |
123143
| simplistic_reexport | bar_attr | simplistic_reexport.py:6:17:6:24 | ControlFlowNode for ImportMember |
144+
| simplistic_reexport | bar_attr | simplistic_reexport.py:10:19:10:26 | ControlFlowNode for bar_attr |
124145
| simplistic_reexport | baz_attr | baz.py:4:1:4:8 | GSSA Variable baz_attr |
125146
| simplistic_reexport | baz_attr | simplistic_reexport.py:17:19:17:26 | ControlFlowNode for baz_attr |
126147
| simplistic_reexport | check | simplistic_reexport.py:17:1:17:5 | ControlFlowNode for check |
127148
| simplistic_reexport | enter | baz.py:2:1:2:5 | ControlFlowNode for enter |
149+
| simplistic_reexport | enter | simplistic_reexport.py:4:1:4:5 | ControlFlowNode for enter |
128150
| simplistic_reexport | exit | baz.py:6:1:6:4 | ControlFlowNode for exit |
129151
| simplistic_reexport | exit | simplistic_reexport.py:19:1:19:4 | ControlFlowNode for exit |
130152
| simplistic_reexport | globals | simplistic_reexport.py:17:44:17:50 | ControlFlowNode for globals |

python/ql/test/experimental/import-resolution/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def local_import():
143143
check("if_then_else_refined.src", if_then_else_refined.src, if_then_else_refined.src, globals()) #$ prints=SOURCE
144144

145145
import simplistic_reexport # $ imports=simplistic_reexport as=simplistic_reexport
146-
check("simplistic_reexport.bar_attr", simplistic_reexport.bar_attr, "overwritten", globals()) #$ MISSING: prints=overwritten SPURIOUS: prints=bar_attr
146+
check("simplistic_reexport.bar_attr", simplistic_reexport.bar_attr, "overwritten", globals()) #$ prints=overwritten SPURIOUS: prints=bar_attr
147147
check("simplistic_reexport.baz_attr", simplistic_reexport.baz_attr, "overwritten", globals()) #$ prints=overwritten SPURIOUS: prints=baz_attr
148148

149149
# check that we don't treat all assignments as being exports

0 commit comments

Comments
 (0)