@@ -54,12 +54,8 @@ module String {
5454 /**
5555 * A flow summary for the `String#%` method.
5656 */
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 = "%" }
6359
6460 override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
6561 input = [ "Receiver" , "Argument[0]" , "Argument[0].ArrayElement" ] and
@@ -72,12 +68,8 @@ module String {
7268 /**
7369 * A flow summary for the `String#b` method.
7470 */
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" }
8173
8274 override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
8375 taintIdentityFlow ( input , output , preservesValue )
@@ -87,12 +79,8 @@ module String {
8779 /**
8880 * A flow summary for the `String#byteslice` method.
8981 */
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" }
9684
9785 override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
9886 taintIdentityFlow ( input , output , preservesValue )
@@ -102,12 +90,8 @@ module String {
10290 /**
10391 * A flow summary for `String#capitalize(!)`.
10492 */
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!" ] }
11195
11296 override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
11397 input = "Receiver" and
@@ -134,12 +118,8 @@ module String {
134118 /**
135119 * A flow summary for the `String#chomp`, `String#chomp!`, `String#chop` and `String#chop!` methods.
136120 */
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!" ] }
143123
144124 override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
145125 taintIdentityFlow ( input , output , preservesValue )
@@ -151,7 +131,15 @@ module String {
151131 }
152132 }
153133
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+
155143 /**
156144 * A flow summary for `String#concat` and `String#prepend`.
157145 */
@@ -213,7 +201,7 @@ module String {
213201 bindingset [ this ]
214202 EachLineSummary ( ) { mc .getMethodName ( ) = [ "each_line" , "lines" ] }
215203
216- override MethodCall getACall ( ) { result = mc }
204+ final override MethodCall getACall ( ) { result = mc }
217205 }
218206
219207 /**
@@ -391,7 +379,7 @@ module String {
391379 bindingset [ this ]
392380 ScanSummary ( ) { mc .getMethodName ( ) = "scan" }
393381
394- override MethodCall getACall ( ) { result = mc }
382+ final override MethodCall getACall ( ) { result = mc }
395383 }
396384
397385 private class ScanBlockSummary extends ScanSummary {
0 commit comments