Skip to content

Commit a8599eb

Browse files
committed
Swift: Use DataFlow::ConfigSig in ECBEncryption.ql
1 parent cc23ba3 commit a8599eb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

swift/ql/src/queries/Security/CWE-327/ECBEncryption.ql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import swift
1414
import codeql.swift.dataflow.DataFlow
1515
import codeql.swift.dataflow.TaintTracking
16-
import DataFlow::PathGraph
16+
import EcbEncryptionFlow::PathGraph
1717

1818
/**
1919
* An `Expr` that is used to initialize the block mode of a cipher.
@@ -54,22 +54,22 @@ class Blowfish extends BlockMode {
5454
* A taint configuration from the constructor of ECB mode to expressions that use
5555
* it to initialize a cipher.
5656
*/
57-
class EcbEncryptionConfig extends DataFlow::Configuration {
58-
EcbEncryptionConfig() { this = "EcbEncryptionConfig" }
59-
60-
override predicate isSource(DataFlow::Node node) {
57+
module EcbEncryptionConfig implements DataFlow::ConfigSig {
58+
predicate isSource(DataFlow::Node node) {
6159
exists(CallExpr call |
6260
call.getStaticTarget().(MethodDecl).hasQualifiedName("ECB", "init()") and
6361
node.asExpr() = call
6462
)
6563
}
6664

67-
override predicate isSink(DataFlow::Node node) { node.asExpr() instanceof BlockMode }
65+
predicate isSink(DataFlow::Node node) { node.asExpr() instanceof BlockMode }
6866
}
6967

68+
module EcbEncryptionFlow = DataFlow::Global<EcbEncryptionConfig>;
69+
7070
// The query itself
71-
from EcbEncryptionConfig config, DataFlow::PathNode sourceNode, DataFlow::PathNode sinkNode
72-
where config.hasFlowPath(sourceNode, sinkNode)
71+
from EcbEncryptionFlow::PathNode sourceNode, EcbEncryptionFlow::PathNode sinkNode
72+
where EcbEncryptionFlow::flowPath(sourceNode, sinkNode)
7373
select sinkNode.getNode(), sourceNode, sinkNode,
7474
"The initialization of the cipher '" + sinkNode.getNode().toString() +
7575
"' uses the insecure ECB block mode from $@.", sourceNode, sourceNode.getNode().toString()

0 commit comments

Comments
 (0)