mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Merge pull request #963 from markshannon/python-sanity-context-sensitive
Python: Make points-to sanity check context sensitive.
This commit is contained in:
@@ -162,14 +162,14 @@ predicate function_object_sanity(string clsname, string problem, string what) {
|
|||||||
|
|
||||||
predicate multiple_origins_per_object(Object obj) {
|
predicate multiple_origins_per_object(Object obj) {
|
||||||
not obj.isC() and not obj instanceof ModuleObject and
|
not obj.isC() and not obj instanceof ModuleObject and
|
||||||
exists(ControlFlowNode use | strictcount(ControlFlowNode orig | use.refersTo(obj, orig)) > 1)
|
exists(ControlFlowNode use, Context ctx | strictcount(ControlFlowNode orig | use.refersTo(ctx, obj, _, orig)) > 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
predicate intermediate_origins(ControlFlowNode use, ControlFlowNode inter, Object obj) {
|
predicate intermediate_origins(ControlFlowNode use, ControlFlowNode inter, Object obj) {
|
||||||
exists(ControlFlowNode orig |
|
exists(ControlFlowNode orig, Context ctx |
|
||||||
not inter = orig |
|
not inter = orig |
|
||||||
use.refersTo(obj, inter) and
|
use.refersTo(ctx, obj, _, inter) and
|
||||||
inter.refersTo(obj, orig) and
|
inter.refersTo(ctx, obj, _, orig) and
|
||||||
// It can sometimes happen that two different modules (e.g. cPickle and Pickle)
|
// It can sometimes happen that two different modules (e.g. cPickle and Pickle)
|
||||||
// have the same attribute, but different origins.
|
// have the same attribute, but different origins.
|
||||||
not strictcount(Object val | inter.(AttrNode).getObject().refersTo(val)) > 1
|
not strictcount(Object val | inter.(AttrNode).getObject().refersTo(val)) > 1
|
||||||
|
|||||||
Reference in New Issue
Block a user