@@ -21,7 +21,7 @@ class StringLengthConflationConfiguration extends DataFlow::Configuration {
2121 // result of a call to to `String.count`
2222 exists ( MemberRefExpr member |
2323 member .getBaseExpr ( ) .getType ( ) .getName ( ) = "String" and
24- member .getMember ( ) .toString ( ) = "count" and // TODO: use of toString
24+ member .getMember ( ) .( VarDecl ) . getName ( ) = "count" and
2525 node .asExpr ( ) = member and
2626 flowstate = "String"
2727 )
@@ -36,28 +36,39 @@ class StringLengthConflationConfiguration extends DataFlow::Configuration {
3636 (
3737 // `NSRange.init`
3838 className = "NSRange" and
39- methodName = "init" and
39+ methodName = "init(location:length:) " and
4040 paramName = [ "location" , "length" ]
4141 or
4242 // `NSString.character`
4343 className = [ "NSString" , "NSMutableString" ] and
44- methodName = "character" and
44+ methodName = "character(at:) " and
4545 paramName = "at"
4646 or
4747 // `NSString.character`
4848 className = [ "NSString" , "NSMutableString" ] and
49- methodName = "substring" and
50- paramName = [ "from" , "to" ]
49+ methodName = "substring(from:)" and
50+ paramName = "from"
51+ or
52+ // `NSString.character`
53+ className = [ "NSString" , "NSMutableString" ] and
54+ methodName = "substring(to:)" and
55+ paramName = "to"
5156 or
5257 // `NSMutableString.insert`
5358 className = "NSMutableString" and
54- methodName = "insert" and
59+ methodName = "insert(_:at:) " and
5560 paramName = "at"
5661 ) and
57- c .toString ( ) = className and // TODO: use of toString
62+ c .getName ( ) = className and
5863 c .getAMember ( ) = f and // TODO: will this even work if its defined in a parent class?
5964 call .getFunction ( ) .( ApplyExpr ) .getFunction ( ) .( DeclRefExpr ) .getDecl ( ) = f and
60- call .getFunction ( ) .( ApplyExpr ) .getFunction ( ) .toString ( ) = methodName and // TODO: use of toString
65+ call .getFunction ( )
66+ .( ApplyExpr )
67+ .getFunction ( )
68+ .( DeclRefExpr )
69+ .getDecl ( )
70+ .( AbstractFunctionDecl )
71+ .getName ( ) = methodName and
6172 f .getParam ( arg ) .getName ( ) = paramName and
6273 call .getArgument ( arg ) .getExpr ( ) = node .asExpr ( ) and
6374 flowstate = "String" // `String` length flowing into `NSString`
0 commit comments