Skip to content

Commit c9c8259

Browse files
authored
Python: Disallow PostUpdateNode as LocalSourceNode
Previously, in cases like ```python def foo(x): x.bar() x.baz() x.quux() ``` we would have flow from the first `x` to each use _and_ flow from the post-update node for each method call to each subsequent use, and all of these would be `LocalSourceNode`s. For large functions with the above pattern, this would lead to a quadratic blowup in `hasLocalSource`. With this commit, only the first of these will count as a `LocalSourceNode`, and the blowup disappears.
1 parent 591ac38 commit c9c8259

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

python/ql/src/semmle/python/dataflow/new/internal/LocalSources.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class LocalSourceNode extends Node {
2626
cached
2727
LocalSourceNode() {
2828
not comes_from_cfgnode(this) and
29-
not this instanceof ModuleVariableNode
29+
not this instanceof ModuleVariableNode and
30+
not this instanceof PostUpdateNode
3031
or
3132
this = any(ModuleVariableNode mvn).getARead()
3233
}

0 commit comments

Comments
 (0)