@@ -83,6 +83,74 @@ module ActiveSupport {
8383 }
8484 }
8585
86+ /**
87+ * Extensions to the `Hash` class.
88+ */
89+ module Hash {
90+ private class WithIndifferentAccessSummary extends SimpleSummarizedCallable {
91+ WithIndifferentAccessSummary ( ) { this = "with_indifferent_access" }
92+
93+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
94+ input = "Argument[self].Element[any]" and
95+ output = "ReturnValue.Element[any]" and
96+ preservesValue = true
97+ }
98+ }
99+
100+ private class TransformSummary extends SimpleSummarizedCallable {
101+ TransformSummary ( ) {
102+ this =
103+ [
104+ "stringify_keys" , "to_options" , "symbolize_keys" , "deep_stringify_keys" ,
105+ "deep_symbolize_keys" , "with_indifferent_access"
106+ ]
107+ }
108+
109+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
110+ input = "Argument[self].Element[any]" and
111+ output = "ReturnValue.Element[?]" and
112+ preservesValue = true
113+ }
114+ }
115+
116+ private string getExtractComponent ( MethodCall mc , int i ) {
117+ mc .getMethodName ( ) = [ "extract!" ] and
118+ result = DataFlow:: Content:: getKnownElementIndex ( mc .getArgument ( i ) ) .serialize ( )
119+ }
120+
121+ private class ExtractSummary extends SummarizedCallable {
122+ MethodCall mc ;
123+
124+ ExtractSummary ( ) {
125+ mc .getMethodName ( ) = "extract!" and
126+ this =
127+ "extract!(" +
128+ concat ( int i , string s | s = getExtractComponent ( mc , i ) | s , "," order by i ) + ")"
129+ }
130+
131+ final override MethodCall getACall ( ) { result = mc }
132+
133+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
134+ (
135+ exists ( string s | s = getExtractComponent ( mc , _) |
136+ input = "Argument[self].Element[" + s + "!]" and
137+ output = "ReturnValue.Element[" + s + "!]"
138+ )
139+ or
140+ input =
141+ "Argument[self]" +
142+ concat ( int i , string s |
143+ s = getExtractComponent ( mc , i )
144+ |
145+ ".WithoutElement[" + s + "!]" order by i
146+ ) + ".WithElement[any]" and
147+ output = "Argument[self]"
148+ ) and
149+ preservesValue = true
150+ }
151+ }
152+ }
153+
86154 /**
87155 * Extensions to the `Enumerable` module.
88156 */
0 commit comments