|
13 | 13 | import swift
|
14 | 14 | import codeql.swift.dataflow.DataFlow
|
15 | 15 | import codeql.swift.dataflow.TaintTracking
|
16 |
| -import DataFlow::PathGraph |
| 16 | +import InsufficientHashIterationsFlow::PathGraph |
17 | 17 |
|
18 | 18 | /**
|
19 | 19 | * An `Expr` that is used to initialize a password-based encryption key.
|
@@ -46,21 +46,19 @@ class InsufficientHashIterationsSink extends Expr {
|
46 | 46 | * A dataflow configuration from the hash iterations source to expressions that use
|
47 | 47 | * it to initialize hash functions.
|
48 | 48 | */
|
49 |
| -class InsufficientHashIterationsConfig extends TaintTracking::Configuration { |
50 |
| - InsufficientHashIterationsConfig() { this = "InsufficientHashIterationsConfig" } |
| 49 | +module InsufficientHashIterationsConfig implements DataFlow::ConfigSig { |
| 50 | + predicate isSource(DataFlow::Node node) { node.asExpr() instanceof IterationsSource } |
51 | 51 |
|
52 |
| - override predicate isSource(DataFlow::Node node) { node.asExpr() instanceof IterationsSource } |
53 |
| - |
54 |
| - override predicate isSink(DataFlow::Node node) { |
55 |
| - node.asExpr() instanceof InsufficientHashIterationsSink |
56 |
| - } |
| 52 | + predicate isSink(DataFlow::Node node) { node.asExpr() instanceof InsufficientHashIterationsSink } |
57 | 53 | }
|
58 | 54 |
|
| 55 | +module InsufficientHashIterationsFlow = TaintTracking::Global<InsufficientHashIterationsConfig>; |
| 56 | + |
59 | 57 | // The query itself
|
60 | 58 | from
|
61 |
| - InsufficientHashIterationsConfig config, DataFlow::PathNode sourceNode, |
62 |
| - DataFlow::PathNode sinkNode |
63 |
| -where config.hasFlowPath(sourceNode, sinkNode) |
| 59 | + InsufficientHashIterationsFlow::PathNode sourceNode, |
| 60 | + InsufficientHashIterationsFlow::PathNode sinkNode |
| 61 | +where InsufficientHashIterationsFlow::flowPath(sourceNode, sinkNode) |
64 | 62 | select sinkNode.getNode(), sourceNode, sinkNode,
|
65 | 63 | "The value '" + sourceNode.getNode().toString() +
|
66 | 64 | "' is an insufficient number of iterations for secure password hashing."
|
0 commit comments