-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[
flake8-bandit
] Implement upstream updates for S311
, S324
and `…
…S605` (#10313) ## Summary Pick up updates made in latest [releases](https://github.com/PyCQA/bandit/releases) of `bandit`: - `S311`: PyCQA/bandit#940 and PyCQA/bandit#1096 - `S324`: PyCQA/bandit#1018 - `S605`: PyCQA/bandit#1116 ## Test Plan Snapshot tests
- Loading branch information
1 parent
ad84eed
commit bc693ea
Showing
10 changed files
with
488 additions
and
221 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
crates/ruff_linter/resources/test/fixtures/flake8_bandit/S311.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
import random | ||
|
||
import a_lib | ||
|
||
# OK | ||
random.SystemRandom() | ||
|
||
# Errors | ||
random.Random() | ||
random.random() | ||
random.randrange() | ||
random.randint() | ||
random.choice() | ||
random.choices() | ||
random.uniform() | ||
random.triangular() | ||
random.randbytes() | ||
|
||
# Unrelated | ||
os.urandom() | ||
a_lib.random() |
43 changes: 19 additions & 24 deletions
43
crates/ruff_linter/resources/test/fixtures/flake8_bandit/S324.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,47 @@ | ||
import crypt | ||
import hashlib | ||
from hashlib import new as hashlib_new | ||
from hashlib import sha1 as hashlib_sha1 | ||
|
||
# Invalid | ||
|
||
# Errors | ||
hashlib.new('md5') | ||
|
||
hashlib.new('md4', b'test') | ||
|
||
hashlib.new(name='md5', data=b'test') | ||
|
||
hashlib.new('MD4', data=b'test') | ||
|
||
hashlib.new('sha1') | ||
|
||
hashlib.new('sha1', data=b'test') | ||
|
||
hashlib.new('sha', data=b'test') | ||
|
||
hashlib.new(name='SHA', data=b'test') | ||
|
||
hashlib.sha(data=b'test') | ||
|
||
hashlib.md5() | ||
|
||
hashlib_new('sha1') | ||
|
||
hashlib_sha1('sha1') | ||
|
||
# usedforsecurity arg only available in Python 3.9+ | ||
hashlib.new('sha1', usedforsecurity=True) | ||
|
||
# Valid | ||
crypt.crypt("test", salt=crypt.METHOD_CRYPT) | ||
crypt.crypt("test", salt=crypt.METHOD_MD5) | ||
crypt.crypt("test", salt=crypt.METHOD_BLOWFISH) | ||
crypt.crypt("test", crypt.METHOD_BLOWFISH) | ||
|
||
hashlib.new('sha256') | ||
crypt.mksalt(crypt.METHOD_CRYPT) | ||
crypt.mksalt(crypt.METHOD_MD5) | ||
crypt.mksalt(crypt.METHOD_BLOWFISH) | ||
|
||
# OK | ||
hashlib.new('sha256') | ||
hashlib.new('SHA512') | ||
|
||
hashlib.sha256(data=b'test') | ||
|
||
# usedforsecurity arg only available in Python 3.9+ | ||
hashlib_new(name='sha1', usedforsecurity=False) | ||
|
||
# usedforsecurity arg only available in Python 3.9+ | ||
hashlib_sha1(name='sha1', usedforsecurity=False) | ||
|
||
# usedforsecurity arg only available in Python 3.9+ | ||
hashlib.md4(usedforsecurity=False) | ||
|
||
# usedforsecurity arg only available in Python 3.9+ | ||
hashlib.new(name='sha256', usedforsecurity=False) | ||
|
||
crypt.crypt("test") | ||
crypt.crypt("test", salt=crypt.METHOD_SHA256) | ||
crypt.crypt("test", salt=crypt.METHOD_SHA512) | ||
|
||
crypt.mksalt() | ||
crypt.mksalt(crypt.METHOD_SHA256) | ||
crypt.mksalt(crypt.METHOD_SHA512) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.