File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
python/ql/lib/semmle/python/dataflow/new/internal Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -292,7 +292,12 @@ module EssaFlow {
292
292
// nodeFrom is `f(42)`, cfg node
293
293
// nodeTo is `x`, essa var
294
294
nodeFrom .( CfgNode ) .getNode ( ) =
295
- nodeTo .( EssaNode ) .getVar ( ) .getDefinition ( ) .( AssignmentDefinition ) .getValue ( )
295
+ nodeTo .( EssaNode ) .getVar ( ) .getDefinition ( ) .( AssignmentDefinition ) .getValue ( ) and
296
+ // we need to ensure that enclosing callable is the same, since a parameter with a
297
+ // default value will be in the scope of the function, while the default value
298
+ // itself will be in the scope that _defines_ the function.
299
+ // We handle _that_ as a jumpstep
300
+ nodeFrom .getEnclosingCallable ( ) = nodeTo .getEnclosingCallable ( )
296
301
or
297
302
// With definition
298
303
// `with f(42) as x:`
@@ -463,6 +468,13 @@ predicate runtimeJumpStep(Node nodeFrom, Node nodeTo) {
463
468
or
464
469
// Setting the possible values of the variable at the end of import time
465
470
nodeFrom = nodeTo .( ModuleVariableNode ) .getADefiningWrite ( )
471
+ or
472
+ // a parameter with a default value, since the parameter will be in the scope of the
473
+ // function, while the default value itself will be in the scope that _defines_ the
474
+ // function.
475
+ nodeFrom .( CfgNode ) .getNode ( ) =
476
+ nodeTo .( EssaNode ) .getVar ( ) .getDefinition ( ) .( AssignmentDefinition ) .getValue ( ) and
477
+ not nodeFrom .getEnclosingCallable ( ) = nodeTo .getEnclosingCallable ( )
466
478
}
467
479
468
480
/**
You can’t perform that action at this time.
0 commit comments