@@ -54,12 +54,8 @@ module String {
54
54
/**
55
55
* A flow summary for the `String#%` method.
56
56
*/
57
- private class FormatSummary extends SummarizedCallable {
58
- private MethodCall mc ;
59
-
60
- FormatSummary ( ) { this = "%" and mc .getMethodName ( ) = this }
61
-
62
- override MethodCall getACall ( ) { result = mc }
57
+ private class FormatSummary extends SimpleSummarizedCallable {
58
+ FormatSummary ( ) { this = "%" }
63
59
64
60
override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
65
61
input = [ "Receiver" , "Argument[0]" , "Argument[0].ArrayElement" ] and
@@ -72,12 +68,8 @@ module String {
72
68
/**
73
69
* A flow summary for the `String#b` method.
74
70
*/
75
- private class BSummary extends SummarizedCallable {
76
- private MethodCall mc ;
77
-
78
- BSummary ( ) { this = "b" and mc .getMethodName ( ) = this }
79
-
80
- override MethodCall getACall ( ) { result = mc }
71
+ private class BSummary extends SimpleSummarizedCallable {
72
+ BSummary ( ) { this = "b" }
81
73
82
74
override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
83
75
taintIdentityFlow ( input , output , preservesValue )
@@ -87,12 +79,8 @@ module String {
87
79
/**
88
80
* A flow summary for the `String#byteslice` method.
89
81
*/
90
- private class BytesliceSummary extends SummarizedCallable {
91
- private MethodCall mc ;
92
-
93
- BytesliceSummary ( ) { this = "byteslice" and mc .getMethodName ( ) = this }
94
-
95
- override MethodCall getACall ( ) { result = mc }
82
+ private class BytesliceSummary extends SimpleSummarizedCallable {
83
+ BytesliceSummary ( ) { this = "byteslice" }
96
84
97
85
override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
98
86
taintIdentityFlow ( input , output , preservesValue )
@@ -102,12 +90,8 @@ module String {
102
90
/**
103
91
* A flow summary for `String#capitalize(!)`.
104
92
*/
105
- private class CapitalizeSummary extends SummarizedCallable {
106
- private MethodCall mc ;
107
-
108
- CapitalizeSummary ( ) { this = [ "capitalize" , "capitalize!" ] and mc .getMethodName ( ) = this }
109
-
110
- override MethodCall getACall ( ) { result = mc }
93
+ private class CapitalizeSummary extends SimpleSummarizedCallable {
94
+ CapitalizeSummary ( ) { this = [ "capitalize" , "capitalize!" ] }
111
95
112
96
override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
113
97
input = "Receiver" and
@@ -134,12 +118,8 @@ module String {
134
118
/**
135
119
* A flow summary for the `String#chomp`, `String#chomp!`, `String#chop` and `String#chop!` methods.
136
120
*/
137
- private class ChompSummary extends SummarizedCallable {
138
- private MethodCall mc ;
139
-
140
- ChompSummary ( ) { this = [ "chomp" , "chomp!" , "chop" , "chop!" ] and mc .getMethodName ( ) = this }
141
-
142
- override MethodCall getACall ( ) { result = mc }
121
+ private class ChompSummary extends SimpleSummarizedCallable {
122
+ ChompSummary ( ) { this = [ "chomp" , "chomp!" , "chop" , "chop!" ] }
143
123
144
124
override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
145
125
taintIdentityFlow ( input , output , preservesValue )
@@ -151,7 +131,15 @@ module String {
151
131
}
152
132
}
153
133
154
- // TODO: we already have a summary for Array#clear. Check that it applies correctly to String#clear.
134
+ /**
135
+ * This is a placeholder for `String#clear`.
136
+ * We can't currently write this summary because there is no `DataFlow::Content` node to refer to (unlike with `Array#clear`).
137
+ * We need a `DataFlow::Content` node in order to override `clearsContent`.
138
+ */
139
+ private class ClearSummary extends SimpleSummarizedCallable {
140
+ ClearSummary ( ) { none ( ) }
141
+ }
142
+
155
143
/**
156
144
* A flow summary for `String#concat` and `String#prepend`.
157
145
*/
@@ -213,7 +201,7 @@ module String {
213
201
bindingset [ this ]
214
202
EachLineSummary ( ) { mc .getMethodName ( ) = [ "each_line" , "lines" ] }
215
203
216
- override MethodCall getACall ( ) { result = mc }
204
+ final override MethodCall getACall ( ) { result = mc }
217
205
}
218
206
219
207
/**
@@ -391,7 +379,7 @@ module String {
391
379
bindingset [ this ]
392
380
ScanSummary ( ) { mc .getMethodName ( ) = "scan" }
393
381
394
- override MethodCall getACall ( ) { result = mc }
382
+ final override MethodCall getACall ( ) { result = mc }
395
383
}
396
384
397
385
private class ScanBlockSummary extends ScanSummary {
0 commit comments