Skip to content

Commit

Permalink
document that random.choices() isn't secure either (PyCQA#728)
Browse files Browse the repository at this point in the history
* document that random.choices() isn't secure either

* add random.choices() to tests
  • Loading branch information
taybin authored and mikespallino committed Jan 7, 2022
1 parent e0feb95 commit 5225fd1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions bandit/blacklists/calls.py
Expand Up @@ -191,6 +191,7 @@
| | | - random.randrange | |
| | | - random.randint | |
| | | - random.choice | |
| | | - random.choices | |
| | | - random.uniform | |
| | | - random.triangular | |
+------+---------------------+------------------------------------+-----------+
Expand Down Expand Up @@ -447,6 +448,7 @@ def gen_blacklist():
'random.randrange',
'random.randint',
'random.choice',
'random.choices',
'random.uniform',
'random.triangular'],
'Standard pseudo-random generators are not suitable for '
Expand Down
1 change: 1 addition & 0 deletions examples/random_module.py
Expand Up @@ -6,6 +6,7 @@
bad = random.randrange()
bad = random.randint()
bad = random.choice()
bad = random.choices()
bad = random.uniform()
bad = random.triangular()

Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_functional.py
Expand Up @@ -355,8 +355,8 @@ def test_popen_wrappers(self):
def test_random_module(self):
'''Test for the `random` module.'''
expect = {
'SEVERITY': {'UNDEFINED': 0, 'LOW': 6, 'MEDIUM': 0, 'HIGH': 0},
'CONFIDENCE': {'UNDEFINED': 0, 'LOW': 0, 'MEDIUM': 0, 'HIGH': 6}
'SEVERITY': {'UNDEFINED': 0, 'LOW': 7, 'MEDIUM': 0, 'HIGH': 0},
'CONFIDENCE': {'UNDEFINED': 0, 'LOW': 0, 'MEDIUM': 0, 'HIGH': 7}
}
self.check_example('random_module.py', expect)

Expand Down

0 comments on commit 5225fd1

Please sign in to comment.