Skip to content

Commit d4faa78

Browse files
authored
document that random.choices() isn't secure either (#728)
* document that random.choices() isn't secure either * add random.choices() to tests
1 parent 2bd1ffa commit d4faa78

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Diff for: bandit/blacklists/calls.py

+2
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@
191191
| | | - random.randrange | |
192192
| | | - random.randint | |
193193
| | | - random.choice | |
194+
| | | - random.choices | |
194195
| | | - random.uniform | |
195196
| | | - random.triangular | |
196197
+------+---------------------+------------------------------------+-----------+
@@ -447,6 +448,7 @@ def gen_blacklist():
447448
'random.randrange',
448449
'random.randint',
449450
'random.choice',
451+
'random.choices',
450452
'random.uniform',
451453
'random.triangular'],
452454
'Standard pseudo-random generators are not suitable for '

Diff for: examples/random_module.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
bad = random.randrange()
77
bad = random.randint()
88
bad = random.choice()
9+
bad = random.choices()
910
bad = random.uniform()
1011
bad = random.triangular()
1112

Diff for: tests/functional/test_functional.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ def test_popen_wrappers(self):
355355
def test_random_module(self):
356356
'''Test for the `random` module.'''
357357
expect = {
358-
'SEVERITY': {'UNDEFINED': 0, 'LOW': 6, 'MEDIUM': 0, 'HIGH': 0},
359-
'CONFIDENCE': {'UNDEFINED': 0, 'LOW': 0, 'MEDIUM': 0, 'HIGH': 6}
358+
'SEVERITY': {'UNDEFINED': 0, 'LOW': 7, 'MEDIUM': 0, 'HIGH': 0},
359+
'CONFIDENCE': {'UNDEFINED': 0, 'LOW': 0, 'MEDIUM': 0, 'HIGH': 7}
360360
}
361361
self.check_example('random_module.py', expect)
362362

0 commit comments

Comments
 (0)