1+ /**
2+ * Provides predicates and classes for working with the standard library implementations of
3+ * [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) and
4+ * [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
5+ */
6+
17import javascript
28private import semmle.javascript.dataflow.internal.StepSummary
39private import DataFlow:: PseudoProperties
@@ -83,7 +89,7 @@ module MapsAndSetsTypeTracking {
8389 exists ( MapOrSetFlowStep step , string field |
8490 summary = LoadStep ( field ) and
8591 step .load ( pred , result , field ) and
86- ( not step .canLoadKnownKey ( ) or not field = mapValueUnknownKey ( ) ) // for a step that could load a known key, we prune the steps where the key is unknown.
92+ ( not step .canLoadKnownKey ( ) or not field = mapValueUnknownKey ( ) ) // for a step that could load a known key, we prune the steps where the key is unknown.
8793 or
8894 summary = StoreStep ( field ) and
8995 step .store ( pred , result , field )
@@ -118,7 +124,7 @@ module MapsAndSetsTypeTracking {
118124 any ( MapOrSetFlowStep step ) .store ( _, _, this )
119125 }
120126
121- override string getLoadStoreToProp ( ) {
127+ override string getLoadStoreToProp ( ) {
122128 exists ( MapOrSetFlowStep step | step .loadStore ( _, _, this , result ) )
123129 }
124130 }
@@ -163,9 +169,9 @@ private module MapAndSetDataFlow {
163169 * A step for a `for of` statement on a Map, Set, or Iterator.
164170 * For Sets and iterators the l-value are the elements of the set/iterator.
165171 * For Maps the l-value is a tuple containing a key and a value.
166- *
167- * This is partially duplicated behavior with the `for of` step for Arrays (in Arrays.qll).
168- * This duplication is required for the type-tracking steps defined in `MapsAndSetsTypeTracking`.
172+ *
173+ * This is partially duplicated behavior with the `for of` step for Arrays (in Arrays.qll).
174+ * This duplication is required for the type-tracking steps defined in `MapsAndSetsTypeTracking`.
169175 */
170176 private class ForOfStep extends MapOrSetFlowStep , DataFlow:: ValueNode {
171177 ForOfStmt forOf ;
@@ -223,9 +229,9 @@ private module MapAndSetDataFlow {
223229
224230 /**
225231 * A call to the `set` method on a Map.
226- *
227- * If the key of the call to `set` has a known string value,
228- * then the value will be saved into a pseudo-property corresponding to the known string value.
232+ *
233+ * If the key of the call to `set` has a known string value,
234+ * then the value will be saved into a pseudo-property corresponding to the known string value.
229235 * The value will additionally be saved into a pseudo-property corresponding to values with unknown keys.
230236 */
231237 private class MapSet extends MapOrSetFlowStep , DataFlow:: MethodCallNode {
@@ -239,9 +245,9 @@ private module MapAndSetDataFlow {
239245 }
240246 }
241247
242- /**
248+ /**
243249 * A step for a call to `values` on a Map or a Set.
244- */
250+ */
245251 private class MapAndSetValues extends MapOrSetFlowStep , DataFlow:: MethodCallNode {
246252 MapAndSetValues ( ) { this .getMethodName ( ) = "values" }
247253
@@ -250,14 +256,14 @@ private module MapAndSetDataFlow {
250256 ) {
251257 pred = this .getReceiver ( ) and
252258 succ = this and
253- fromProp = [ mapValueUnknownKey ( ) , setElement ( ) ] and
259+ fromProp = [ mapValueUnknownKey ( ) , setElement ( ) ] and
254260 toProp = iteratorElement ( )
255261 }
256262 }
257263
258- /**
264+ /**
259265 * A step for a call to `keys` on a Set.
260- */
266+ */
261267 private class SetKeys extends MapOrSetFlowStep , DataFlow:: MethodCallNode {
262268 SetKeys ( ) { this .getMethodName ( ) = "keys" }
263269
0 commit comments