11private import javascript
22private import semmle.javascript.frameworks.data.internal.ApiGraphModels as ApiGraphModels
3+ private import semmle.javascript.dataflow.internal.FlowSummaryPrivate as FlowSummaryPrivate
4+ private import codeql.dataflow.internal.AccessPathSyntax as AccessPathSyntax
35
46module Private {
57 import Public
@@ -15,6 +17,15 @@ module Private {
1517 /** Gets the largest array index should be propagated precisely through flow summaries. */
1618 int getAPreciseArrayIndex ( ) { result = [ 0 .. getMaxPreciseArrayIndex ( ) ] }
1719
20+ /**
21+ * Holds if a MaD access path token of form `name[arg]` exists.
22+ */
23+ predicate isAccessPathTokenPresent ( string name , string arg ) {
24+ arg = any ( FlowSummaryPrivate:: AccessPathToken tok ) .getAnArgument ( name )
25+ or
26+ arg = any ( ApiGraphModels:: AccessPathToken tok ) .getAnArgument ( name )
27+ }
28+
1829 /**
1930 * Holds if values associated with `key` should be tracked as a individual contents of a `Map` object.
2031 */
@@ -25,10 +36,7 @@ module Private {
2536 call .getArgument ( 0 ) .getStringValue ( ) = key
2637 )
2738 or
28- exists ( ApiGraphModels:: AccessPathToken token |
29- token .getName ( ) = "MapValue" and
30- token .getAnArgument ( ) = key
31- )
39+ isAccessPathTokenPresent ( "MapValue" , key )
3240 }
3341
3442 /**
@@ -47,9 +55,7 @@ module Private {
4755 or
4856 this = getAPreciseArrayIndex ( ) .toString ( )
4957 or
50- exists ( ApiGraphModels:: AccessPathToken tok |
51- tok .getName ( ) = "Member" and this = tok .getAnArgument ( )
52- )
58+ isAccessPathTokenPresent ( "Member" , this )
5359 }
5460
5561 /** Gets the array index corresponding to this property name. */
0 commit comments