@@ -467,14 +467,22 @@ class BarrierGuard extends GuardNode {
467467 }
468468}
469469
470+ private predicate comes_from_cfgnode ( Node node ) {
471+ exists ( CfgNode first , Node second |
472+ simpleLocalFlowStep ( first , second ) and
473+ simpleLocalFlowStep * ( second , node )
474+ )
475+ }
476+
470477/**
471478 * A data flow node that is a source of local flow. This includes things like
472479 * - Expressions
473480 * - Function parameters
474481 */
475482class LocalSourceNode extends Node {
483+ cached
476484 LocalSourceNode ( ) {
477- not simpleLocalFlowStep + ( any ( CfgNode n ) , this ) and
485+ not comes_from_cfgnode ( this ) and
478486 not this instanceof ModuleVariableNode
479487 or
480488 this = any ( ModuleVariableNode mvn ) .getARead ( )
@@ -522,15 +530,12 @@ private module Cached {
522530 * The slightly backwards parametering ordering is to force correct indexing.
523531 */
524532 cached
525- predicate hasLocalSource ( Node sink , Node source ) {
526- // Declaring `source` to be a `SourceNode` currently causes a redundant check in the
527- // recursive case, so instead we check it explicitly here.
528- source = sink and
529- source instanceof LocalSourceNode
533+ predicate hasLocalSource ( Node sink , LocalSourceNode source ) {
534+ source = sink
530535 or
531- exists ( Node mid |
532- hasLocalSource ( mid , source ) and
533- simpleLocalFlowStep ( mid , sink )
536+ exists ( Node second |
537+ simpleLocalFlowStep ( source , second ) and
538+ simpleLocalFlowStep * ( second , sink )
534539 )
535540 }
536541
0 commit comments