mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Python: Fix bad join in globalVariableNestedFieldJumpStep
This commit is contained in:
@@ -561,18 +561,36 @@ predicate runtimeJumpStep(Node nodeFrom, Node nodeTo) {
|
|||||||
globalVariableNestedFieldJumpStep(nodeFrom, nodeTo)
|
globalVariableNestedFieldJumpStep(nodeFrom, nodeTo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Helper predicate for `globalVariableNestedFieldJumpStep`. */
|
||||||
|
pragma[nomagic]
|
||||||
|
private predicate globalVariableAttrPathRead(
|
||||||
|
ModuleVariableNode globalVar, string accessPath, AttrRead r, string attrName
|
||||||
|
) {
|
||||||
|
globalVariableAttrPathAtDepth(globalVar, accessPath, r.getObject(), _) and
|
||||||
|
attrName = r.getAttributeName()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Helper predicate for `globalVariableNestedFieldJumpStep`. */
|
||||||
|
pragma[nomagic]
|
||||||
|
private predicate globalVariableAttrPathWrite(
|
||||||
|
ModuleVariableNode globalVar, string accessPath, AttrWrite w, string attrName
|
||||||
|
) {
|
||||||
|
globalVariableAttrPathAtDepth(globalVar, accessPath, w.getObject(), _) and
|
||||||
|
attrName = w.getAttributeName()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds if there is a jump step from `nodeFrom` to `nodeTo` through global variable field access.
|
* Holds if there is a jump step from `nodeFrom` to `nodeTo` through global variable field access.
|
||||||
* This supports tracking nested object field access through global variables like `app.obj.foo`.
|
* This supports tracking nested object field access through global variables like `app.obj.foo`.
|
||||||
*/
|
*/
|
||||||
|
pragma[nomagic]
|
||||||
private predicate globalVariableNestedFieldJumpStep(Node nodeFrom, Node nodeTo) {
|
private predicate globalVariableNestedFieldJumpStep(Node nodeFrom, Node nodeTo) {
|
||||||
exists(ModuleVariableNode globalVar, AttrWrite write, AttrRead read |
|
exists(ModuleVariableNode globalVar, AttrWrite write, AttrRead read |
|
||||||
// Match writes and reads on the same global variable attribute path
|
// Match writes and reads on the same global variable attribute path
|
||||||
exists(string accessPath |
|
exists(string accessPath, string attrName |
|
||||||
globalVariableAttrPathAtDepth(globalVar, accessPath, write.getObject(), _) and
|
globalVariableAttrPathRead(globalVar, accessPath, read, attrName) and
|
||||||
globalVariableAttrPathAtDepth(globalVar, accessPath, read.getObject(), _)
|
globalVariableAttrPathWrite(globalVar, accessPath, write, attrName)
|
||||||
) and
|
) and
|
||||||
write.getAttributeName() = read.getAttributeName() and
|
|
||||||
nodeFrom = write.getValue() and
|
nodeFrom = write.getValue() and
|
||||||
nodeTo = read
|
nodeTo = read
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user