Merge pull request #1482 from markshannon/python-fix-odasa-7104

Backport #1407 to rc/1.21
This commit is contained in:
Taus 2019-06-21 15:05:32 +02:00 коммит произвёл GitHub
Родитель 8b58b80e5f bbf25f3a23
Коммит 1c91b926a8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 22 добавлений и 2 удалений

Просмотреть файл

@ -726,10 +726,12 @@ private module InterModulePointsTo {
|
src.declaredInAll(name) and result = true
or
src.declaredInAll(_) and not src.declaredInAll(name) and
declared_all_is_simple(src) and
not src.declaredInAll(name) and
ofInterestInExports(mod, name) and result = false
or
not src.declaredInAll(_) and
(not src.declaredInAll(name) and not declared_all_is_simple(src))
and
exists(ObjectInternal val |
ModuleAttributes::pointsToAtExit(src, name, val, _) |
val = ObjectInternal::undefined() and result = false
@ -739,6 +741,17 @@ private module InterModulePointsTo {
)
}
/** Holds if __all__ is declared and not mutated */
private predicate declared_all_is_simple(Module m) {
exists(AssignStmt a, GlobalVariable all |
a.defines(all) and a.getScope() = m and
all.getId() = "__all__" and
not exists(Attribute attr |
all.getALoad() = attr.getObject()
)
)
}
private boolean packageExportsBoolean(PackageObjectInternal mod, string name) {
exists(Folder folder |
folder = mod.getFolder() |

Просмотреть файл

@ -52,4 +52,6 @@
| test.py | 24 | ControlFlowNode for argv | int 0 | ControlFlowNode for IntegerLiteral |
| test.py | 27 | ControlFlowNode for ImportExpr | Module sys | ControlFlowNode for ImportExpr |
| test.py | 31 | ControlFlowNode for argv | list object | ControlFlowNode for from sys import * |
| test.py | 33 | ControlFlowNode for ImportExpr | Module socket | ControlFlowNode for ImportExpr |
| test.py | 34 | ControlFlowNode for timeout | builtin-class socket.timeout | ControlFlowNode for from _socket import * |
| x.py | 2 | ControlFlowNode for ImportExpr | Module sys | ControlFlowNode for ImportExpr |

Просмотреть файл

@ -52,4 +52,6 @@
| test.py | 24 | ControlFlowNode for argv | int 0 | builtin-class int | ControlFlowNode for IntegerLiteral |
| test.py | 27 | ControlFlowNode for ImportExpr | Module sys | builtin-class module | ControlFlowNode for ImportExpr |
| test.py | 31 | ControlFlowNode for argv | list object | builtin-class list | ControlFlowNode for from sys import * |
| test.py | 33 | ControlFlowNode for ImportExpr | Module socket | builtin-class module | ControlFlowNode for ImportExpr |
| test.py | 34 | ControlFlowNode for timeout | builtin-class socket.timeout | builtin-class type | ControlFlowNode for from _socket import * |
| x.py | 2 | ControlFlowNode for ImportExpr | Module sys | builtin-class module | ControlFlowNode for ImportExpr |

Просмотреть файл

@ -29,3 +29,6 @@ except:
pass
argv
from socket import *
timeout