@@ -23,10 +23,6 @@ abstract class ModuleObjectInternal extends ObjectInternal {
2323 none ( )
2424 }
2525
26- override ControlFlowNode getOrigin ( ) {
27- result = this .getSourceModule ( ) .getEntryNode ( )
28- }
29-
3026 override boolean isClass ( ) { result = false }
3127
3228 override boolean isComparable ( ) { result = true }
@@ -92,6 +88,10 @@ class BuiltinModuleObjectInternal extends ModuleObjectInternal, TBuiltinModuleOb
9288
9389 override predicate attributesUnknown ( ) { none ( ) }
9490
91+ override ControlFlowNode getOrigin ( ) {
92+ none ( )
93+ }
94+
9595}
9696
9797class PackageObjectInternal extends ModuleObjectInternal , TPackageObject {
@@ -154,18 +154,14 @@ class PackageObjectInternal extends ModuleObjectInternal, TPackageObject {
154154 override predicate attribute ( string name , ObjectInternal value , CfgOrigin origin ) {
155155 this .getInitModule ( ) .attribute ( name , value , origin )
156156 or
157- // TO DO, dollar variable...
158- //exists(Module init |
159- // init = this.getSourceModule() and
160- // not exists(EssaVariable var | var.getAUse() = init.getANormalExit() and var.getSourceVariable().getName() = name) and
161- // exists(EssaVariable var, Context context |
162- // isModuleStateVariable(var) and var.getAUse() = init.getANormalExit() and
163- // context.isImport() and
164- // SSA::ssa_variable_named_attribute_pointsTo(var, context, name, undefinedVariable(), _, origin) and
165- // value = this.submodule(name)
166- // )
167- //)
168- //or
157+ exists ( Module init |
158+ init = this .getSourceModule ( ) and
159+ not exists ( EssaVariable var | var .getAUse ( ) = init .getANormalExit ( ) and var .getSourceVariable ( ) .getName ( ) = name ) and
160+ ModuleAttributes:: pointsToAtExit ( init , name , ObjectInternal:: undefined ( ) , _) and
161+ value = this .submodule ( name ) and
162+ origin = CfgOrigin:: fromModule ( value )
163+ )
164+ or
169165 this .hasNoInitModule ( ) and
170166 exists ( ModuleObjectInternal mod |
171167 mod = this .submodule ( name ) and
@@ -176,6 +172,10 @@ class PackageObjectInternal extends ModuleObjectInternal, TPackageObject {
176172
177173 override predicate attributesUnknown ( ) { none ( ) }
178174
175+ override ControlFlowNode getOrigin ( ) {
176+ none ( )
177+ }
178+
179179}
180180
181181/** Get the ESSA pseudo-variable used to retain module state
@@ -249,5 +249,9 @@ class PythonModuleObjectInternal extends ModuleObjectInternal, TPythonModule {
249249
250250 override predicate attributesUnknown ( ) { none ( ) }
251251
252+ override ControlFlowNode getOrigin ( ) {
253+ result = this .getSourceModule ( ) .getEntryNode ( )
254+ }
255+
252256}
253257
0 commit comments