@@ -17,8 +17,8 @@ private import codeql.ruby.dataflow.internal.DataFlowDispatch
1717 */
1818module Hash {
1919 // cannot use API graphs due to negative recursion
20- private predicate isHashLiteralPair ( Pair pair , ConstantValue cv ) {
21- cv = DataFlow:: Content:: getKnownElementIndex ( pair .getKey ( ) ) and
20+ private predicate isHashLiteralPair ( Pair pair , ConstantValue key ) {
21+ key = DataFlow:: Content:: getKnownElementIndex ( pair .getKey ( ) ) and
2222 pair = any ( MethodCall mc | mc .getMethodName ( ) = "[]" ) .getAnArgument ( )
2323 }
2424
@@ -44,23 +44,23 @@ module Hash {
4444 }
4545
4646 private class HashLiteralNonSymbolSummary extends SummarizedCallable {
47- private ConstantValue cv ;
47+ private ConstantValue key ;
4848
4949 HashLiteralNonSymbolSummary ( ) {
5050 this = "Hash.[]" and
51- isHashLiteralPair ( _, cv ) and
52- not cv .isSymbol ( _)
51+ isHashLiteralPair ( _, key ) and
52+ not key .isSymbol ( _)
5353 }
5454
5555 final override MethodCall getACall ( ) {
5656 result = API:: getTopLevelMember ( "Hash" ) .getAMethodCall ( "[]" ) .getExprNode ( ) .getExpr ( ) and
57- isHashLiteralPair ( result .getAnArgument ( ) , cv )
57+ isHashLiteralPair ( result .getAnArgument ( ) , key )
5858 }
5959
6060 override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
6161 // { 'nonsymbol' => x }
62- input = "Argument[0..].PairValue[" + cv .serialize ( ) + "]" and
63- output = "ReturnValue.Element[" + cv .serialize ( ) + "]" and
62+ input = "Argument[0..].PairValue[" + key .serialize ( ) + "]" and
63+ output = "ReturnValue.Element[" + key .serialize ( ) + "]" and
6464 preservesValue = true
6565 }
6666 }
@@ -110,27 +110,27 @@ module Hash {
110110 */
111111 private class HashNewSuccessivePairsSummary extends SummarizedCallable {
112112 private int i ;
113- private ConstantValue cv ;
113+ private ConstantValue key ;
114114
115115 HashNewSuccessivePairsSummary ( ) {
116- this = "Hash[" + i + ", " + cv .serialize ( ) + "]" and
116+ this = "Hash[" + i + ", " + key .serialize ( ) + "]" and
117117 i % 2 = 1 and
118118 exists ( ElementReference er |
119- cv = er .getArgument ( i - 1 ) .getConstantValue ( ) and
119+ key = er .getArgument ( i - 1 ) .getConstantValue ( ) and
120120 exists ( er .getArgument ( i ) )
121121 )
122122 }
123123
124124 final override ElementReference getACall ( ) {
125125 result .getReceiver ( ) = API:: getTopLevelMember ( "Hash" ) .getAUse ( ) .asExpr ( ) .getExpr ( ) and
126- cv = result .getArgument ( i - 1 ) .getConstantValue ( ) and
126+ key = result .getArgument ( i - 1 ) .getConstantValue ( ) and
127127 exists ( result .getArgument ( i ) )
128128 }
129129
130130 override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
131131 // Hash[:symbol, x]
132132 input = "Argument[" + i + "]" and
133- output = "ReturnValue.Element[" + cv .serialize ( ) + "]" and
133+ output = "ReturnValue.Element[" + key .serialize ( ) + "]" and
134134 preservesValue = true
135135 }
136136 }
@@ -165,21 +165,21 @@ module Hash {
165165 }
166166
167167 private class StoreKnownSummary extends StoreSummary {
168- private ConstantValue cv ;
168+ private ConstantValue key ;
169169
170170 StoreKnownSummary ( ) {
171- cv = DataFlow:: Content:: getKnownElementIndex ( mc .getArgument ( 0 ) ) and
172- this = "store(" + cv .serialize ( ) + ")"
171+ key = DataFlow:: Content:: getKnownElementIndex ( mc .getArgument ( 0 ) ) and
172+ this = "store(" + key .serialize ( ) + ")"
173173 }
174174
175175 override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
176176 super .propagatesFlowExt ( input , output , preservesValue )
177177 or
178178 input = "Argument[1]" and
179- output = "Argument[self].Element[" + cv .serialize ( ) + "]" and
179+ output = "Argument[self].Element[" + key .serialize ( ) + "]" and
180180 preservesValue = true
181181 or
182- input = "Argument[self].WithoutElement[" + cv .serialize ( ) + "]" and
182+ input = "Argument[self].WithoutElement[" + key .serialize ( ) + "]" and
183183 output = "Argument[self]" and
184184 preservesValue = true
185185 }
@@ -210,17 +210,17 @@ module Hash {
210210 }
211211
212212 private class AssocKnownSummary extends AssocSummary {
213- private ConstantValue cv ;
213+ private ConstantValue key ;
214214
215215 AssocKnownSummary ( ) {
216- this = "assoc(" + cv .serialize ( ) + "]" and
217- not cv .isInt ( _) and // exclude arrays
216+ this = "assoc(" + key .serialize ( ) + "]" and
217+ not key .isInt ( _) and // exclude arrays
218218 mc .getNumberOfArguments ( ) = 1 and
219- cv = DataFlow:: Content:: getKnownElementIndex ( mc .getArgument ( 0 ) )
219+ key = DataFlow:: Content:: getKnownElementIndex ( mc .getArgument ( 0 ) )
220220 }
221221
222222 override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
223- input = "Argument[self].Element[" + cv .serialize ( ) + ",?]" and
223+ input = "Argument[self].Element[" + key .serialize ( ) + ",?]" and
224224 output = "ReturnValue.Element[1]" and
225225 preservesValue = true
226226 }
@@ -325,18 +325,18 @@ abstract private class FetchValuesSummary extends SummarizedCallable {
325325}
326326
327327private class FetchValuesKnownSummary extends FetchValuesSummary {
328- ConstantValue cv ;
328+ ConstantValue key ;
329329
330330 FetchValuesKnownSummary ( ) {
331331 forex ( Expr arg | arg = mc .getAnArgument ( ) | exists ( arg .getConstantValue ( ) ) ) and
332- cv = mc .getAnArgument ( ) .getConstantValue ( ) and
333- this = "fetch_values(" + cv .serialize ( ) + ")"
332+ key = mc .getAnArgument ( ) .getConstantValue ( ) and
333+ this = "fetch_values(" + key .serialize ( ) + ")"
334334 }
335335
336336 override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
337337 super .propagatesFlowExt ( input , output , preservesValue )
338338 or
339- input = "Argument[self].Element[" + cv .serialize ( ) + "]" and
339+ input = "Argument[self].Element[" + key .serialize ( ) + "]" and
340340 output = "ReturnValue.Element[?]" and
341341 preservesValue = true
342342 }
@@ -407,16 +407,16 @@ abstract private class SliceSummary extends SummarizedCallable {
407407}
408408
409409private class SliceKnownSummary extends SliceSummary {
410- ConstantValue cv ;
410+ ConstantValue key ;
411411
412412 SliceKnownSummary ( ) {
413- cv = mc .getAnArgument ( ) .getConstantValue ( ) and
414- this = "slice(" + cv .serialize ( ) + ")" and
415- not cv .isInt ( _) // covered in `Array.qll`
413+ key = mc .getAnArgument ( ) .getConstantValue ( ) and
414+ this = "slice(" + key .serialize ( ) + ")" and
415+ not key .isInt ( _) // covered in `Array.qll`
416416 }
417417
418418 override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
419- input = "Argument[self].WithElement[?," + cv .serialize ( ) + "]" and
419+ input = "Argument[self].WithElement[?," + key .serialize ( ) + "]" and
420420 output = "ReturnValue" and
421421 preservesValue = true
422422 }
0 commit comments