@@ -11,6 +11,7 @@ import DataFlowPublic
1111private import DataFlowPrivate
1212private import semmle.python.internal.CachedStages
1313private import semmle.python.internal.Awaited
14+ private import semmle.python.dataflow.new.internal.ImportStar
1415
1516/**
1617 * A data flow node that is a source of local flow. This includes things like
@@ -39,6 +40,22 @@ class LocalSourceNode extends Node {
3940 this instanceof ExprNode and
4041 not simpleLocalFlowStepForTypetracking ( _, this )
4142 or
43+ // For `from foo import *; foo_function()`, we want to let the variables we think
44+ // could originate in `foo` (such as `foo_function`) to be available in the API
45+ // graph. This requires them to be local sources. They would not be from the code
46+ // just above, since the CFG node has flow going into it from its corresponding
47+ // `GlobalSsaVariable`. (a different work-around is to change API graphs to not rely
48+ // as heavily on LocalSourceNode; I initially tried this, but it relied on a lot of
49+ // copy-pasted code, and it requires some non-trivial deprecation for downgrading
50+ // the result type of `.asSource()` to DataFlow::Node, so we've opted for this
51+ // approach instead).
52+ //
53+ // Note: This is only needed at the module level -- uses inside functions appear as
54+ // LocalSourceNodes as we expect.
55+ //
56+ // TODO: When rewriting SSA, we should be able to remove this workaround
57+ ImportStar:: namePossiblyDefinedInImportStar ( this .( ExprNode ) .getNode ( ) , _, any ( Module m ) )
58+ or
4259 // We include all module variable nodes, as these act as stepping stones between writes and
4360 // reads of global variables. Without them, type tracking based on `LocalSourceNode`s would be
4461 // unable to track across global variables.
0 commit comments