@@ -11,6 +11,7 @@ import DataFlowPublic
11
11
private import DataFlowPrivate
12
12
private import semmle.python.internal.CachedStages
13
13
private import semmle.python.internal.Awaited
14
+ private import semmle.python.dataflow.new.internal.ImportStar
14
15
15
16
/**
16
17
* A data flow node that is a source of local flow. This includes things like
@@ -39,6 +40,22 @@ class LocalSourceNode extends Node {
39
40
this instanceof ExprNode and
40
41
not simpleLocalFlowStepForTypetracking ( _, this )
41
42
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
42
59
// We include all module variable nodes, as these act as stepping stones between writes and
43
60
// reads of global variables. Without them, type tracking based on `LocalSourceNode`s would be
44
61
// unable to track across global variables.
0 commit comments