Skip to content

Commit 60f033f

Browse files
committed
Swift: Use DataFlow::ConfigSig in ConstantSalt.ql
1 parent b97b3d9 commit 60f033f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

swift/ql/src/queries/Security/CWE-760/ConstantSalt.ql

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import swift
1414
import codeql.swift.dataflow.DataFlow
1515
import codeql.swift.dataflow.TaintTracking
1616
import codeql.swift.dataflow.FlowSteps
17-
import DataFlow::PathGraph
17+
import ConstantSaltFlow::PathGraph
1818

1919
/**
2020
* A constant salt is created through either a byte array or string literals.
@@ -52,19 +52,19 @@ class ConstantSaltSink extends Expr {
5252

5353
/**
5454
* A taint configuration from the source of constants salts to expressions that use
55-
* them to initialize password-based enecryption keys.
55+
* them to initialize password-based encryption keys.
5656
*/
57-
class ConstantSaltConfig extends TaintTracking::Configuration {
58-
ConstantSaltConfig() { this = "ConstantSaltConfig" }
57+
module ConstantSaltConfig implements DataFlow::ConfigSig {
58+
predicate isSource(DataFlow::Node node) { node.asExpr() instanceof ConstantSaltSource }
5959

60-
override predicate isSource(DataFlow::Node node) { node.asExpr() instanceof ConstantSaltSource }
61-
62-
override predicate isSink(DataFlow::Node node) { node.asExpr() instanceof ConstantSaltSink }
60+
predicate isSink(DataFlow::Node node) { node.asExpr() instanceof ConstantSaltSink }
6361
}
6462

63+
module ConstantSaltFlow = TaintTracking::Global<ConstantSaltConfig>;
64+
6565
// The query itself
66-
from ConstantSaltConfig config, DataFlow::PathNode sourceNode, DataFlow::PathNode sinkNode
67-
where config.hasFlowPath(sourceNode, sinkNode)
66+
from ConstantSaltFlow::PathNode sourceNode, ConstantSaltFlow::PathNode sinkNode
67+
where ConstantSaltFlow::flowPath(sourceNode, sinkNode)
6868
select sinkNode.getNode(), sourceNode, sinkNode,
6969
"The value '" + sourceNode.getNode().toString() +
7070
"' is used as a constant salt, which is insecure for hashing passwords."

0 commit comments

Comments
 (0)