@@ -14,26 +14,24 @@ import swift
14
14
import codeql.swift.dataflow.DataFlow
15
15
import codeql.swift.dataflow.TaintTracking
16
16
import codeql.swift.dataflow.FlowSources
17
- import DataFlow :: PathGraph
17
+ import InsecureTlsFlow :: PathGraph
18
18
19
19
/**
20
20
* A taint config to detect insecure configuration of `NSURLSessionConfiguration`
21
21
*/
22
- class InsecureTlsConfig extends TaintTracking:: Configuration {
23
- InsecureTlsConfig ( ) { this = "InsecureTLSConfig" }
24
-
22
+ module InsecureTlsConfig implements DataFlow:: ConfigSig {
25
23
/**
26
24
* Holds for enum values that represent an insecure version of TLS
27
25
*/
28
- override predicate isSource ( DataFlow:: Node node ) {
26
+ predicate isSource ( DataFlow:: Node node ) {
29
27
node .asExpr ( ) .( MethodLookupExpr ) .getMember ( ) .( EnumElementDecl ) .getName ( ) =
30
28
[ "TLSv10" , "TLSv11" , "tlsProtocol10" , "tlsProtocol11" ]
31
29
}
32
30
33
31
/**
34
32
* Holds for assignment of TLS-related properties of `NSURLSessionConfiguration`
35
33
*/
36
- override predicate isSink ( DataFlow:: Node node ) {
34
+ predicate isSink ( DataFlow:: Node node ) {
37
35
exists ( AssignExpr assign |
38
36
assign .getSource ( ) = node .asExpr ( ) and
39
37
assign .getDest ( ) .( MemberRefExpr ) .getMember ( ) .( ConcreteVarDecl ) .getName ( ) =
@@ -45,6 +43,8 @@ class InsecureTlsConfig extends TaintTracking::Configuration {
45
43
}
46
44
}
47
45
48
- from InsecureTlsConfig config , DataFlow:: PathNode sourceNode , DataFlow:: PathNode sinkNode
49
- where config .hasFlowPath ( sourceNode , sinkNode )
46
+ module InsecureTlsFlow = TaintTracking:: Global< InsecureTlsConfig > ;
47
+
48
+ from InsecureTlsFlow:: PathNode sourceNode , InsecureTlsFlow:: PathNode sinkNode
49
+ where InsecureTlsFlow:: flowPath ( sourceNode , sinkNode )
50
50
select sinkNode .getNode ( ) , sourceNode , sinkNode , "This TLS configuration is insecure."
0 commit comments