@@ -115,37 +115,6 @@ class Portal extends TPortal {
115115 abstract int depth ( ) ;
116116}
117117
118- /**
119- * Gets an exit node for the specified portal, using TypeTracking.
120- *
121- * Called in instances where an exit node is computed from another exit node
122- * (for example, in MemberPortal's portalBaseRef predicate).
123- */
124- private DataFlow:: SourceNode trackExitNode (
125- Portal base , boolean isRemote , DataFlow:: TypeTracker t
126- ) {
127- t .start ( ) and
128- result = base .getAnExitNode ( isRemote )
129- or
130- exists ( DataFlow:: TypeTracker t2 | result = trackExitNode ( base , isRemote , t2 ) .track ( t2 , t ) )
131- }
132-
133- /**
134- * Gets an entry node for the specified portal, using TypeBackTracking.
135- *
136- * Parallel to trackExitNode above.
137- */
138- private DataFlow:: SourceNode trackEntryNode (
139- Portal base , boolean escapes , DataFlow:: TypeBackTracker t
140- ) {
141- t .start ( ) and
142- result = base .getAnEntryNode ( escapes ) .getALocalSource ( )
143- or
144- exists ( DataFlow:: TypeBackTracker t2 |
145- result = trackEntryNode ( base , escapes , t2 ) .backtrack ( t2 , t )
146- )
147- }
148-
149118/**
150119 * A portal representing the exports value of the main module of an npm
151120 * package (that is, a value of `module.exports` for CommonJS modules, or
@@ -291,9 +260,9 @@ private class MemberPortal extends CompoundPortal, MkMemberPortal {
291260private module MemberPortal {
292261 /** Gets a node representing a value flowing through `base`, that is, either an entry node or an exit node. */
293262 private DataFlow:: SourceNode portalBaseRef ( Portal base , boolean escapes ) {
294- result = trackExitNode ( base , escapes , DataFlow :: TypeTracker :: end ( ) )
263+ result = base . getAnExitNode ( escapes )
295264 or
296- result = trackEntryNode ( base , escapes , DataFlow :: TypeBackTracker :: end ( ) )
265+ result = base . getAnEntryNode ( escapes ) . getALocalSource ( )
297266 }
298267
299268 /** Holds if `read` is a read of property `prop` of a value flowing through `base`. */
@@ -373,13 +342,13 @@ private module InstancePortal {
373342 Portal base , DataFlow:: SourceNode ctor , AbstractInstance i , boolean escapes
374343 ) {
375344 ctor = DataFlow:: valueNode ( i .getConstructor ( ) .getDefinition ( ) ) and
376- ctor = trackEntryNode ( base , escapes , DataFlow :: TypeBackTracker :: end ( ) ) and
345+ ctor . flowsTo ( base . getAnEntryNode ( escapes ) ) and
377346 instantiable ( ctor )
378347 }
379348
380349 /** Holds if `nd` is an expression evaluating to an instance of `base`. */
381350 predicate instanceUse ( Portal base , DataFlow:: SourceNode nd , boolean isRemote ) {
382- nd = trackExitNode ( base , isRemote , DataFlow :: TypeTracker :: end ( ) ) .getAnInstantiation ( )
351+ nd = base . getAnExitNode ( isRemote ) .getAnInstantiation ( )
383352 or
384353 isInstance ( base , _, nd .analyze ( ) .getAValue ( ) , isRemote )
385354 }
@@ -446,14 +415,13 @@ class ParameterPortal extends CompoundPortal, MkParameterPortal {
446415private module ParameterPortal {
447416 /** Holds if `param` is the `i`th parameter of a function flowing through `base`. */
448417 predicate parameter ( Portal base , int i , DataFlow:: SourceNode param , boolean isRemote ) {
449- param = trackEntryNode ( base , isRemote , DataFlow:: TypeBackTracker:: end ( ) ) .( DataFlow:: FunctionNode )
450- .getParameter ( i )
418+ param = base .getAnEntryNode ( isRemote ) .getALocalSource ( ) .( DataFlow:: FunctionNode ) .getParameter ( i )
451419 }
452420
453421 /** Holds if `arg` is the `i`th argument passed to an invocation of a function flowing through `base`. */
454422 predicate argument ( Portal base , int i , DataFlow:: Node arg , boolean escapes ) {
455423 exists ( DataFlow:: InvokeNode invk |
456- invk = trackExitNode ( base , escapes , DataFlow :: TypeTracker :: end ( ) ) .getAnInvocation ( ) and
424+ invk = base . getAnExitNode ( escapes ) .getAnInvocation ( ) and
457425 arg = invk .getArgument ( i )
458426 )
459427 }
@@ -481,14 +449,11 @@ class ReturnPortal extends CompoundPortal, MkReturnPortal {
481449private module ReturnPortal {
482450 /** Holds if `invk` is a call to a function flowing through `callee`. */
483451 predicate calls ( DataFlow:: InvokeNode invk , Portal callee , boolean isRemote ) {
484- invk = trackExitNode ( callee , isRemote , DataFlow:: TypeTracker:: end ( ) )
485- .getAnInvocation ( )
452+ invk = callee .getAnExitNode ( isRemote ) .getAnInvocation ( )
486453 }
487454
488455 /** Holds if `ret` is a return node of a function flowing through `callee`. */
489456 predicate returns ( Portal base , DataFlow:: Node ret , boolean escapes ) {
490- ret = trackEntryNode ( base , escapes , DataFlow:: TypeBackTracker:: end ( ) )
491- .( DataFlow:: FunctionNode )
492- .getAReturn ( )
457+ ret = base .getAnEntryNode ( escapes ) .getALocalSource ( ) .( DataFlow:: FunctionNode ) .getAReturn ( )
493458 }
494459}
0 commit comments