Skip to content

Commit 4224822

Browse files
committed
Swift: Use DataFlow::ConfigSig in WeakSensitiveDataHashing.ql
1 parent a8599eb commit 4224822

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

swift/ql/src/queries/Security/CWE-328/WeakSensitiveDataHashing.ql

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ import swift
1515
import codeql.swift.security.SensitiveExprs
1616
import codeql.swift.dataflow.DataFlow
1717
import codeql.swift.dataflow.TaintTracking
18-
import DataFlow::PathGraph
18+
import WeakHashingFlow::PathGraph
1919

20-
class WeakHashingConfig extends TaintTracking::Configuration {
21-
WeakHashingConfig() { this = "WeakHashingConfig" }
20+
module WeakHashingConfig implements DataFlow::ConfigSig {
21+
predicate isSource(DataFlow::Node node) { node instanceof WeakHashingConfigImpl::Source }
2222

23-
override predicate isSource(DataFlow::Node node) { node instanceof WeakHashingConfig::Source }
24-
25-
override predicate isSink(DataFlow::Node node) { node instanceof WeakHashingConfig::Sink }
23+
predicate isSink(DataFlow::Node node) { node instanceof WeakHashingConfigImpl::Sink }
2624
}
2725

28-
module WeakHashingConfig {
26+
module WeakHashingFlow = TaintTracking::Global<WeakHashingConfig>;
27+
28+
module WeakHashingConfigImpl {
2929
class Source extends DataFlow::Node {
3030
Source() { this.asExpr() instanceof SensitiveExpr }
3131
}
@@ -52,11 +52,11 @@ module WeakHashingConfig {
5252
}
5353

5454
from
55-
WeakHashingConfig config, DataFlow::PathNode source, DataFlow::PathNode sink, string algorithm,
55+
WeakHashingFlow::PathNode source, WeakHashingFlow::PathNode sink, string algorithm,
5656
SensitiveExpr expr
5757
where
58-
config.hasFlowPath(source, sink) and
59-
algorithm = sink.getNode().(WeakHashingConfig::Sink).getAlgorithm() and
58+
WeakHashingFlow::flowPath(source, sink) and
59+
algorithm = sink.getNode().(WeakHashingConfigImpl::Sink).getAlgorithm() and
6060
expr = source.getNode().asExpr()
6161
select sink.getNode(), source, sink,
6262
"Insecure hashing algorithm (" + algorithm + ") depends on $@.", source.getNode(),

0 commit comments

Comments
 (0)