Skip to content

Commit 53e57da

Browse files
committed
Python: Move experimental InsecureRandomness to new dataflow API
1 parent 3bf2705 commit 53e57da

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

python/ql/src/experimental/Security/CWE-338/InsecureRandomness.ql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
*/
1515

1616
import python
17-
import experimental.semmle.python.security.InsecureRandomness::InsecureRandomness
17+
import experimental.semmle.python.security.InsecureRandomness
1818
import semmle.python.dataflow.new.DataFlow
19-
import DataFlow::PathGraph
2019

21-
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
22-
where cfg.hasFlowPath(source, sink)
20+
import InsecureRandomness::Flow::PathGraph
21+
22+
from InsecureRandomness::Flow::PathNode source, InsecureRandomness::Flow::PathNode sink
23+
where InsecureRandomness::Flow::flowPath(source, sink)
2324
select sink.getNode(), source, sink, "Cryptographically insecure $@ in a security context.",
2425
source.getNode(), "random value"

python/ql/src/experimental/semmle/python/security/InsecureRandomness.qll

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,14 @@ module InsecureRandomness {
2121
* A taint-tracking configuration for reasoning about random values that are
2222
* not cryptographically secure.
2323
*/
24-
class Configuration extends TaintTracking::Configuration {
25-
Configuration() { this = "InsecureRandomness" }
24+
private module Configuration implements DataFlow::ConfigSig {
25+
predicate isSource(DataFlow::Node source) { source instanceof Source }
2626

27-
override predicate isSource(DataFlow::Node source) { source instanceof Source }
27+
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
2828

29-
override predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
30-
31-
override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer }
32-
33-
deprecated override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) {
34-
guard instanceof SanitizerGuard
35-
}
29+
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
3630
}
31+
32+
/** Global taint-tracking for detecting "random values that are not cryptographically secure" vulnerabilities. */
33+
module Flow = TaintTracking::Global<Configuration>;
3734
}

0 commit comments

Comments
 (0)