|
12 | 12 | */ |
13 | 13 |
|
14 | 14 | import python |
15 | | -private import LegacyPointsTo |
| 15 | +import semmle.python.dataflow.new.DataFlow |
| 16 | +private import semmle.python.dataflow.new.internal.ImportResolution |
16 | 17 | import semmle.python.filters.Tests |
17 | 18 |
|
18 | | -from ImportMember im, ModuleValue m, AttrNode store_attr, string name |
| 19 | +from ImportMember im, Module m, DataFlow::AttrWrite store_attr, string name |
19 | 20 | where |
20 | | - m.importedAs(im.getModule().(ImportExpr).getImportedModuleName()) and |
| 21 | + ImportResolution::getImmediateModuleReference(m).asExpr() = im.getModule() and |
21 | 22 | im.getName() = name and |
22 | 23 | /* Modification must be in a function, so it can occur during lifetime of the import value */ |
23 | | - store_attr.getScope() instanceof Function and |
| 24 | + store_attr.getObject().getScope() instanceof Function and |
24 | 25 | /* variable resulting from import must have a long lifetime */ |
25 | 26 | not im.getScope() instanceof Function and |
26 | | - store_attr.isStore() and |
27 | | - store_attr.getObject(name).(ControlFlowNodeWithPointsTo).pointsTo(m) and |
| 27 | + store_attr.getAttributeName() = name and |
| 28 | + ImportResolution::getModuleReference(m) = store_attr.getObject() and |
28 | 29 | /* Import not in same module as modification. */ |
29 | | - not im.getEnclosingModule() = store_attr.getScope().getEnclosingModule() and |
| 30 | + not im.getEnclosingModule() = store_attr.getObject().getScope().getEnclosingModule() and |
30 | 31 | /* Modification is not in a test */ |
31 | | - not store_attr.getScope().getScope*() instanceof TestScope |
| 32 | + not store_attr.getObject().getScope().getScope*() instanceof TestScope |
32 | 33 | select im, |
33 | 34 | "Importing the value of '" + name + |
34 | 35 | "' from $@ means that any change made to $@ will be not be observed locally.", m, |
35 | | - "module " + m.getName(), store_attr, m.getName() + "." + store_attr.getName() |
| 36 | + "module " + ImportResolution::moduleName(m), store_attr, |
| 37 | + ImportResolution::moduleName(m) + "." + store_attr.getAttributeName() |
0 commit comments