Skip to content

Commit 1dd15fa

Browse files
author
liangjinhuang
committed
style:auto format
1 parent 976e484 commit 1dd15fa

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

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"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import random
22

3+
34
def generatePassword():
45
# BAD: the random is not cryptographically secure
56
return random.random()
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import secrets
22

3+
34
def generatePassword():
45
# GOOD: the random is cryptographically secure
56
secret_generator = secrets.SystemRandom()
6-
return secret_generator.random()
7+
return secret_generator.random()

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ module InsecureRandomness {
5858
class RandomFnSink extends Sink {
5959
RandomFnSink() {
6060
exists(DataFlowCallable randomFn |
61-
randomFn.getName().regexpMatch("(?i).*(gen(erate)?|make|mk|create).*(nonce|salt|pepper|Password).*")
61+
randomFn
62+
.getName()
63+
.regexpMatch("(?i).*(gen(erate)?|make|mk|create).*(nonce|salt|pepper|Password).*")
6264
|
6365
this.getEnclosingCallable() = randomFn
6466
)

0 commit comments

Comments
 (0)