@@ -14,7 +14,7 @@ import swift
1414import codeql.swift.dataflow.DataFlow
1515import codeql.swift.dataflow.TaintTracking
1616import 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 )
6868select 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