@@ -32,70 +32,58 @@ abstract class Sink extends DataFlow::Node { }
3232class WKWebView extends Sink {
3333 WKWebView ( ) {
3434 any ( CallExpr ce |
35- ce .getStaticTarget ( ) =
36- getMethodWithQualifiedName ( "WKWebView" ,
37- [
38- "evaluateJavaScript(_:)" , "evaluateJavaScript(_:completionHandler:)" ,
39- "evaluateJavaScript(_:in:in:completionHandler:)" ,
40- "evaluateJavaScript(_:in:contentWorld:)" ,
41- "callAsyncJavaScript(_:arguments:in:in:completionHandler:)" ,
42- "callAsyncJavaScript(_:arguments:in:contentWorld:)"
43- ] )
35+ ce .getStaticTarget ( )
36+ .( MethodDecl )
37+ .hasQualifiedName ( "WKWebView" ,
38+ [
39+ "evaluateJavaScript(_:)" , "evaluateJavaScript(_:completionHandler:)" ,
40+ "evaluateJavaScript(_:in:in:completionHandler:)" ,
41+ "evaluateJavaScript(_:in:contentWorld:)" ,
42+ "callAsyncJavaScript(_:arguments:in:in:completionHandler:)" ,
43+ "callAsyncJavaScript(_:arguments:in:contentWorld:)"
44+ ] )
4445 ) .getArgument ( 0 ) .getExpr ( ) = this .asExpr ( )
4546 }
4647}
4748
4849class WKUserContentController extends Sink {
4950 WKUserContentController ( ) {
5051 any ( CallExpr ce |
51- ce .getStaticTarget ( ) =
52- getMethodWithQualifiedName ( "WKUserContentController" , "addUserScript(_:)" )
52+ ce .getStaticTarget ( )
53+ .( MethodDecl )
54+ .hasQualifiedName ( "WKUserContentController" , "addUserScript(_:)" )
5355 ) .getArgument ( 0 ) .getExpr ( ) = this .asExpr ( )
5456 }
5557}
5658
5759class UIWebView extends Sink {
5860 UIWebView ( ) {
5961 any ( CallExpr ce |
60- ce .getStaticTarget ( ) =
61- getMethodWithQualifiedName ( [ "UIWebView" , "WebView" ] , "stringByEvaluatingJavaScript(from:)" )
62+ ce .getStaticTarget ( )
63+ .( MethodDecl )
64+ .hasQualifiedName ( [ "UIWebView" , "WebView" ] , "stringByEvaluatingJavaScript(from:)" )
6265 ) .getArgument ( 0 ) .getExpr ( ) = this .asExpr ( )
6366 }
6467}
6568
6669class JSContext extends Sink {
6770 JSContext ( ) {
6871 any ( CallExpr ce |
69- ce .getStaticTarget ( ) =
70- getMethodWithQualifiedName ( "JSContext" ,
71- [ "evaluateScript(_:)" , "evaluateScript(_:withSourceURL:)" ] )
72+ ce .getStaticTarget ( )
73+ . ( MethodDecl )
74+ . hasQualifiedName ( "JSContext" , [ "evaluateScript(_:)" , "evaluateScript(_:withSourceURL:)" ] )
7275 ) .getArgument ( 0 ) .getExpr ( ) = this .asExpr ( )
7376 }
7477}
7578
7679class JSEvaluateScript extends Sink {
7780 JSEvaluateScript ( ) {
7881 any ( CallExpr ce |
79- ce .getStaticTarget ( ) = getFunctionWithQualifiedName ( "JSEvaluateScript(_:_:_:_:_:_:)" )
82+ ce .getStaticTarget ( ) . ( FreeFunctionDecl ) . hasName ( "JSEvaluateScript(_:_:_:_:_:_:)" )
8083 ) .getArgument ( 1 ) .getExpr ( ) = this .asExpr ( )
8184 }
8285}
8386
84- // TODO: Consider moving the following to the library, e.g.
85- // - Decl.hasQualifiedName(moduleName?, declaringDeclName?, declName)
86- // - parentDecl = memberDecl.getDeclaringDecl() <=> parentDecl.getAMember() = memberDecl
87- IterableDeclContext getDeclaringDeclOf ( Decl member ) { result .getAMember ( ) = member }
88-
89- MethodDecl getMethodWithQualifiedName ( string className , string methodName ) {
90- result .getName ( ) = methodName and
91- getDeclaringDeclOf ( result ) .( NominalTypeDecl ) .getName ( ) = className
92- }
93-
94- AbstractFunctionDecl getFunctionWithQualifiedName ( string funcName ) {
95- result .getName ( ) = funcName and
96- not result .hasSelfParam ( )
97- }
98-
9987/**
10088 * A taint configuration from taint sources to sinks for this query.
10189 */
0 commit comments