@@ -95,40 +95,43 @@ class StringLengthConflationAdditionalTaintStep extends Unit {
9595 abstract predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) ;
9696}
9797
98+ /**
99+ * A source defined in a CSV model.
100+ */
98101private class DefaultStringLengthConflationSource extends StringLengthConflationSource {
99102 StringType stringType ;
100103
101- DefaultStringLengthConflationSource ( ) {
102- exists ( MemberRefExpr memberRef , string className , string varName |
103- memberRef .getBase ( ) .getType ( ) .( NominalType ) .getABaseType * ( ) .getName ( ) = className and
104- memberRef .getMember ( ) .( VarDecl ) .getName ( ) = varName and
104+ DefaultStringLengthConflationSource ( ) { sourceNode ( this , stringType .getCsvLabel ( ) ) }
105+
106+ override StringType getStringType ( ) { result = stringType }
107+ }
108+
109+ private class StringLengthConflationSources extends SourceModelCsv {
110+ override predicate row ( string row ) {
111+ row =
112+ [
113+ ";String;true;count;;;;string-length" ,
114+ ";String.UTF8View;true;count;;;;string-utf8-length" ,
115+ ";String.UTF16View;true;count;;;;string-utf16-length" ,
116+ ";NSString;true;length;;;;nsstring-length" ,
117+ ";NSMutableString;true;length;;;;nsstring-length" ,
118+ ]
119+ }
120+ }
121+
122+ /**
123+ * An extra source that don't currently fit into the CSV scheme.
124+ */
125+ private class ExtraStringLengthConflationSource extends StringLengthConflationSource {
126+ StringType stringType ;
127+
128+ ExtraStringLengthConflationSource ( ) {
129+ exists ( MemberRefExpr memberRef |
130+ // result of a call to `String.unicodeScalars.count`
131+ memberRef .getBase ( ) .getType ( ) .( NominalType ) .getName ( ) = "String.UnicodeScalarView" and
132+ memberRef .getMember ( ) .( VarDecl ) .getName ( ) = "count" and
105133 this .asExpr ( ) = memberRef and
106- (
107- // result of a call to `String.count`
108- className = "String" and
109- varName = "count" and
110- stringType = "String"
111- or
112- // result of a call to `NSString.length`
113- className = [ "NSString" , "NSMutableString" ] and
114- varName = "length" and
115- stringType = "NSString"
116- or
117- // result of a call to `String.utf8.count`
118- className = "String.UTF8View" and
119- varName = "count" and
120- stringType = "String.utf8"
121- or
122- // result of a call to `String.utf16.count`
123- className = "String.UTF16View" and
124- varName = "count" and
125- stringType = "String.utf16"
126- or
127- // result of a call to `String.unicodeScalars.count`
128- className = "String.UnicodeScalarView" and
129- varName = "count" and
130- stringType = "String.unicodeScalars"
131- )
134+ stringType = "String.unicodeScalars"
132135 )
133136 }
134137
0 commit comments