зеркало из https://github.com/github/codeql.git
Python: Autoformat query
This commit is contained in:
Родитель
816a8d1f9e
Коммит
647b9cdcb0
|
@ -10,22 +10,25 @@
|
|||
* @precision medium
|
||||
* @id py/import-of-mutable-attribute
|
||||
*/
|
||||
|
||||
import python
|
||||
import semmle.python.filters.Tests
|
||||
|
||||
from ImportMember im, ModuleObject m, AttrNode store_attr, string name
|
||||
where im.getModule().(ImportExpr).getImportedModuleName() = m.getName() and
|
||||
im.getName() = name and
|
||||
/* Modification must be in a function, so it can occur during lifetime of the import value */
|
||||
store_attr.getScope() instanceof Function and
|
||||
/* variable resulting from import must have a long lifetime */
|
||||
not im.getScope() instanceof Function and
|
||||
store_attr.isStore() and
|
||||
store_attr.getObject(name).refersTo(m) and
|
||||
/* Import not in same module as modification. */
|
||||
not im.getEnclosingModule() = store_attr.getScope().getEnclosingModule() and
|
||||
/* Modification is not in a test */
|
||||
not store_attr.getScope().getScope*() instanceof TestScope
|
||||
|
||||
select im, "Importing the value of '" + name + "' from $@ means that any change made to $@ will be not be observed locally.",
|
||||
m, "module " + m.getName(), store_attr, m.getName() + "." + store_attr.getName()
|
||||
where
|
||||
im.getModule().(ImportExpr).getImportedModuleName() = m.getName() and
|
||||
im.getName() = name and
|
||||
/* Modification must be in a function, so it can occur during lifetime of the import value */
|
||||
store_attr.getScope() instanceof Function and
|
||||
/* variable resulting from import must have a long lifetime */
|
||||
not im.getScope() instanceof Function and
|
||||
store_attr.isStore() and
|
||||
store_attr.getObject(name).refersTo(m) and
|
||||
/* Import not in same module as modification. */
|
||||
not im.getEnclosingModule() = store_attr.getScope().getEnclosingModule() and
|
||||
/* Modification is not in a test */
|
||||
not store_attr.getScope().getScope*() instanceof TestScope
|
||||
select im,
|
||||
"Importing the value of '" + name +
|
||||
"' from $@ means that any change made to $@ will be not be observed locally.", m,
|
||||
"module " + m.getName(), store_attr, m.getName() + "." + store_attr.getName()
|
||||
|
|
Загрузка…
Ссылка в новой задаче