|
13 | 13 | import swift
|
14 | 14 | import codeql.swift.dataflow.DataFlow
|
15 | 15 | import codeql.swift.dataflow.TaintTracking
|
16 |
| -import DataFlow::PathGraph |
| 16 | +import EcbEncryptionFlow::PathGraph |
17 | 17 |
|
18 | 18 | /**
|
19 | 19 | * An `Expr` that is used to initialize the block mode of a cipher.
|
@@ -54,22 +54,22 @@ class Blowfish extends BlockMode {
|
54 | 54 | * A taint configuration from the constructor of ECB mode to expressions that use
|
55 | 55 | * it to initialize a cipher.
|
56 | 56 | */
|
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) { |
61 | 59 | exists(CallExpr call |
|
62 | 60 | call.getStaticTarget().(MethodDecl).hasQualifiedName("ECB", "init()") and
|
63 | 61 | node.asExpr() = call
|
64 | 62 | )
|
65 | 63 | }
|
66 | 64 |
|
67 |
| - override predicate isSink(DataFlow::Node node) { node.asExpr() instanceof BlockMode } |
| 65 | + predicate isSink(DataFlow::Node node) { node.asExpr() instanceof BlockMode } |
68 | 66 | }
|
69 | 67 |
|
| 68 | +module EcbEncryptionFlow = DataFlow::Global<EcbEncryptionConfig>; |
| 69 | + |
70 | 70 | // 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) |
73 | 73 | select sinkNode.getNode(), sourceNode, sinkNode,
|
74 | 74 | "The initialization of the cipher '" + sinkNode.getNode().toString() +
|
75 | 75 | "' uses the insecure ECB block mode from $@.", sourceNode, sourceNode.getNode().toString()
|
0 commit comments