@@ -32,70 +32,58 @@ abstract class Sink extends DataFlow::Node { }
32
32
class WKWebView extends Sink {
33
33
WKWebView ( ) {
34
34
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
+ ] )
44
45
) .getArgument ( 0 ) .getExpr ( ) = this .asExpr ( )
45
46
}
46
47
}
47
48
48
49
class WKUserContentController extends Sink {
49
50
WKUserContentController ( ) {
50
51
any ( CallExpr ce |
51
- ce .getStaticTarget ( ) =
52
- getMethodWithQualifiedName ( "WKUserContentController" , "addUserScript(_:)" )
52
+ ce .getStaticTarget ( )
53
+ .( MethodDecl )
54
+ .hasQualifiedName ( "WKUserContentController" , "addUserScript(_:)" )
53
55
) .getArgument ( 0 ) .getExpr ( ) = this .asExpr ( )
54
56
}
55
57
}
56
58
57
59
class UIWebView extends Sink {
58
60
UIWebView ( ) {
59
61
any ( CallExpr ce |
60
- ce .getStaticTarget ( ) =
61
- getMethodWithQualifiedName ( [ "UIWebView" , "WebView" ] , "stringByEvaluatingJavaScript(from:)" )
62
+ ce .getStaticTarget ( )
63
+ .( MethodDecl )
64
+ .hasQualifiedName ( [ "UIWebView" , "WebView" ] , "stringByEvaluatingJavaScript(from:)" )
62
65
) .getArgument ( 0 ) .getExpr ( ) = this .asExpr ( )
63
66
}
64
67
}
65
68
66
69
class JSContext extends Sink {
67
70
JSContext ( ) {
68
71
any ( CallExpr ce |
69
- ce .getStaticTarget ( ) =
70
- getMethodWithQualifiedName ( "JSContext" ,
71
- [ "evaluateScript(_:)" , "evaluateScript(_:withSourceURL:)" ] )
72
+ ce .getStaticTarget ( )
73
+ . ( MethodDecl )
74
+ . hasQualifiedName ( "JSContext" , [ "evaluateScript(_:)" , "evaluateScript(_:withSourceURL:)" ] )
72
75
) .getArgument ( 0 ) .getExpr ( ) = this .asExpr ( )
73
76
}
74
77
}
75
78
76
79
class JSEvaluateScript extends Sink {
77
80
JSEvaluateScript ( ) {
78
81
any ( CallExpr ce |
79
- ce .getStaticTarget ( ) = getFunctionWithQualifiedName ( "JSEvaluateScript(_:_:_:_:_:_:)" )
82
+ ce .getStaticTarget ( ) . ( FreeFunctionDecl ) . hasName ( "JSEvaluateScript(_:_:_:_:_:_:)" )
80
83
) .getArgument ( 1 ) .getExpr ( ) = this .asExpr ( )
81
84
}
82
85
}
83
86
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
-
99
87
/**
100
88
* A taint configuration from taint sources to sinks for this query.
101
89
*/
0 commit comments