Skip to content

Commit b97b3d9

Browse files
committed
Swift: Use DtatFlow::ConfigSig in InsecureTLS.ql
1 parent 4224822 commit b97b3d9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

swift/ql/src/queries/Security/CWE-757/InsecureTLS.ql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,24 @@ import swift
1414
import codeql.swift.dataflow.DataFlow
1515
import codeql.swift.dataflow.TaintTracking
1616
import codeql.swift.dataflow.FlowSources
17-
import DataFlow::PathGraph
17+
import InsecureTlsFlow::PathGraph
1818

1919
/**
2020
* A taint config to detect insecure configuration of `NSURLSessionConfiguration`
2121
*/
22-
class InsecureTlsConfig extends TaintTracking::Configuration {
23-
InsecureTlsConfig() { this = "InsecureTLSConfig" }
24-
22+
module InsecureTlsConfig implements DataFlow::ConfigSig {
2523
/**
2624
* Holds for enum values that represent an insecure version of TLS
2725
*/
28-
override predicate isSource(DataFlow::Node node) {
26+
predicate isSource(DataFlow::Node node) {
2927
node.asExpr().(MethodLookupExpr).getMember().(EnumElementDecl).getName() =
3028
["TLSv10", "TLSv11", "tlsProtocol10", "tlsProtocol11"]
3129
}
3230

3331
/**
3432
* Holds for assignment of TLS-related properties of `NSURLSessionConfiguration`
3533
*/
36-
override predicate isSink(DataFlow::Node node) {
34+
predicate isSink(DataFlow::Node node) {
3735
exists(AssignExpr assign |
3836
assign.getSource() = node.asExpr() and
3937
assign.getDest().(MemberRefExpr).getMember().(ConcreteVarDecl).getName() =
@@ -45,6 +43,8 @@ class InsecureTlsConfig extends TaintTracking::Configuration {
4543
}
4644
}
4745

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)
5050
select sinkNode.getNode(), sourceNode, sinkNode, "This TLS configuration is insecure."

0 commit comments

Comments
 (0)