mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
python: instantiate module for variable capture
This provides variable capture in standard situations: - nested functions - lambdas There are some deficiencies: - we do not yet handle objects capturing variables. - we do not handle variables captured via the `nonlocal` keyword. This should be solved at the AST level, though, and then it should "just work". There are still inconsistencies in the case where a `SynthesizedCaptureNode` has a comprehensions as its enclosing callable. In this case, `TFunction(cn.getEnclosingCallable())` is not defined and so getEnclosingCallable does not exist for the `CaptureNode`.
This commit is contained in:
@@ -34,17 +34,17 @@ def SINK_F(x):
|
||||
def inParam(tainted):
|
||||
def captureIn1():
|
||||
sinkI1 = tainted
|
||||
SINK(sinkI1) #$ MISSING:captured
|
||||
SINK(sinkI1) #$ captured
|
||||
captureIn1()
|
||||
|
||||
def captureIn2():
|
||||
def m():
|
||||
sinkI2 = tainted
|
||||
SINK(sinkI2) #$ MISSING:captured
|
||||
SINK(sinkI2) #$ captured
|
||||
m()
|
||||
captureIn2()
|
||||
|
||||
captureIn3 = lambda arg: SINK(tainted)
|
||||
captureIn3 = lambda arg: SINK(tainted) #$ captured
|
||||
captureIn3("")
|
||||
|
||||
def captureIn1NotCalled():
|
||||
@@ -68,17 +68,17 @@ def inLocal():
|
||||
|
||||
def captureIn1():
|
||||
sinkI1 = tainted
|
||||
SINK(sinkI1) #$ MISSING:captured
|
||||
SINK(sinkI1) #$ captured
|
||||
captureIn1()
|
||||
|
||||
def captureIn2():
|
||||
def m():
|
||||
sinkI2 = tainted
|
||||
SINK(sinkI2) #$ MISSING:captured
|
||||
SINK(sinkI2) #$ captured
|
||||
m()
|
||||
captureIn2()
|
||||
|
||||
captureIn3 = lambda arg: SINK(tainted) #$ MISSING:captured
|
||||
captureIn3 = lambda arg: SINK(tainted) #$ captured
|
||||
captureIn3("")
|
||||
|
||||
def captureIn1NotCalled():
|
||||
|
||||
Reference in New Issue
Block a user