@@ -131,8 +131,8 @@ private class StringSummaries extends SummaryModelCsv {
131131}
132132
133133/**
134- * A content implying that, if a `String` is tainted, then many of its fields are
135- * tainted. This also includes fields declared in `StringProtocol` .
134+ * A content implying that, if a `String`, `StringProtocol` or related class is tainted, then many
135+ * of its fields are tainted .
136136 */
137137private class StringFieldsInheritTaint extends TaintInheritingContent ,
138138 DataFlow:: Content:: FieldContent
@@ -141,12 +141,24 @@ private class StringFieldsInheritTaint extends TaintInheritingContent,
141141 this .getField ( )
142142 .hasQualifiedName ( [ "String" , "StringProtocol" ] ,
143143 [
144- "unicodeScalars" , "utf8" , "utf16" , "lazy" , "utf8CString" , "description" ,
145- "debugDescription" , "dataValue" , "identifierValue" , "capitalized" ,
146- "localizedCapitalized" , "localizedLowercase" , "localizedUppercase" ,
147- "decomposedStringWithCanonicalMapping" , "decomposedStringWithCompatibilityMapping" ,
148- "precomposedStringWithCanonicalMapping" , "precomposedStringWithCompatibilityMapping" ,
149- "removingPercentEncoding"
144+ "unicodeScalars" , "utf8" , "utf16" , "lazy" , "utf8CString" , "dataValue" ,
145+ "identifierValue" , "capitalized" , "localizedCapitalized" , "localizedLowercase" ,
146+ "localizedUppercase" , "decomposedStringWithCanonicalMapping" ,
147+ "decomposedStringWithCompatibilityMapping" , "precomposedStringWithCanonicalMapping" ,
148+ "precomposedStringWithCompatibilityMapping" , "removingPercentEncoding"
150149 ] )
150+ or
151+ exists ( FieldDecl fieldDecl , Decl declaringDecl , TypeDecl namedTypeDecl |
152+ (
153+ namedTypeDecl .getFullName ( ) = "CustomStringConvertible" and
154+ fieldDecl .getName ( ) = "description"
155+ or
156+ namedTypeDecl .getFullName ( ) = "CustomDebugStringConvertible" and
157+ fieldDecl .getName ( ) = "debugDescription"
158+ ) and
159+ declaringDecl .getAMember ( ) = fieldDecl and
160+ declaringDecl .asNominalTypeDecl ( ) = namedTypeDecl .getADerivedTypeDecl * ( ) and
161+ this .getField ( ) = fieldDecl
162+ )
151163 }
152164}
0 commit comments