Skip to content

Commit 1885b68

Browse files
author
liangjinhuang
committed
style:formatDocument
1 parent af2e8ff commit 1885b68

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

python/ql/lib/semmle/python/security/dataflow/InsecureRandomness.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import semmle.python.dataflow.new.TaintTracking
1616
*/
1717
module InsecureRandomness {
1818
import InsecureRandomnessCustomizations::InsecureRandomness
19-
19+
2020
/**
2121
* A taint-tracking configuration for reasoning about random values that are
2222
* not cryptographically secure.
@@ -29,9 +29,9 @@ module InsecureRandomness {
2929
override predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
3030

3131
override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer }
32-
32+
3333
override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) {
3434
guard instanceof SanitizerGuard
3535
}
3636
}
37-
}
37+
}

python/ql/lib/semmle/python/security/dataflow/InsecureRandomnessCustomizations.qll

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,20 @@ module InsecureRandomness {
3838
* A random source that is not sufficient for security use. So far this is only made up
3939
* of the math package's rand function, more insufficient random sources can be added here.
4040
*/
41-
class InsecureRandomSource extends Source {
42-
InsecureRandomSource() {
41+
class InsecureRandomSource extends Source {
42+
InsecureRandomSource() {
4343
this =
4444
API::moduleImport("random")
4545
.getMember([
46-
"betavariate", "choice", "choices", "expovariate",
47-
"gammavariate", "gauss", "getrandbits", "getstate",
48-
"lognormvariate", "normalvariate", "paretovariate",
49-
"randbytes", "randint", "random", "randrange",
50-
"sample", "seed", "setstate", "shuffle",
51-
"triangular", "uniform", "vonmisesvariate", "weibullvariate"
46+
"betavariate", "choice", "choices", "expovariate", "gammavariate", "gauss",
47+
"getrandbits", "getstate", "lognormvariate", "normalvariate", "paretovariate",
48+
"randbytes", "randint", "random", "randrange", "sample", "seed", "setstate",
49+
"shuffle", "triangular", "uniform", "vonmisesvariate", "weibullvariate"
5250
])
5351
.getACall()
5452
}
5553
}
56-
54+
5755
/**
5856
* A use in a function that heuristically deals with unsafe random numbers or random strings.
5957
*/
@@ -73,9 +71,7 @@ module InsecureRandomness {
7371
*/
7472
class CryptoKeySink extends Sink {
7573
CryptoKeySink() {
76-
exists(Cryptography::CryptographicOperation operation |
77-
this = operation.getAnInput()
78-
)
74+
exists(Cryptography::CryptographicOperation operation | this = operation.getAnInput())
7975
}
8076
}
81-
}
77+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ import DataFlow::PathGraph
2020
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
2121
where cfg.hasFlowPath(source, sink)
2222
select sink.getNode(), source, sink, "Cryptographically insecure $@ in a security context.",
23-
source.getNode(), "random value"
23+
source.getNode(), "random value"

0 commit comments

Comments
 (0)