Skip to content

Commit e5f9788

Browse files
Update query message and remove field case
1 parent be068cd commit e5f9788

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

python/ql/src/Variables/LoopVariableCapture.ql

+9-6
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ module EscapingCaptureFlowSig implements DataFlow::ConfigSig {
3434

3535
predicate isSink(DataFlow::Node node) {
3636
// Stored in a field.
37-
exists(DataFlow::AttrWrite aw | aw.getObject() = node)
38-
or
37+
// This appeared to lead to FPs through wrapper classes.
38+
// exists(DataFlow::AttrWrite aw | aw.getObject() = node)
39+
// or
3940
// Stored in a dict/list.
4041
exists(Assign assign, Subscript sub |
4142
sub = assign.getATarget() and node.asExpr() = assign.getValue()
@@ -44,7 +45,7 @@ module EscapingCaptureFlowSig implements DataFlow::ConfigSig {
4445
// Stored in a list.
4546
exists(DataFlow::MethodCallNode mc | mc.calls(_, "append") and node = mc.getArg(0))
4647
or
47-
// Used in a yeild statement, likely included in a collection.
48+
// Used in a yield statement, likely included in a collection.
4849
// The element of comprehension expressions desugar to involve a yield statement internally.
4950
exists(Yield y | node.asExpr() = y.getValue())
5051
}
@@ -64,6 +65,8 @@ predicate escapingCapture(CallableExpr capturing, Loop loop, Variable var) {
6465
EscapingCaptureFlow::flow(DataFlow::exprNode(capturing), _)
6566
}
6667

67-
from CallableExpr capturing, AstNode loop, Variable var
68-
where escapingCapture(capturing, loop, var)
69-
select capturing, "Capture of loop variable $@.", loop, var.getId()
68+
from CallableExpr capturing, AstNode loop, Variable var, string descr
69+
where
70+
escapingCapture(capturing, loop, var) and
71+
if capturing instanceof Lambda then descr = "lambda" else descr = "function"
72+
select capturing, "This " + descr + " captures the loop variable $@.", loop, var.getId()

0 commit comments

Comments
 (0)