-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix eval detection for suspicious-eval-usage (#5506)
Closes #5505.
- Loading branch information
1 parent
0b963dd
commit 521e6de
Showing
7 changed files
with
52 additions
and
15 deletions.
There are no files selected for viewing
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,12 @@ | ||
import os | ||
|
||
print(eval("1+1")) # S307 | ||
print(eval("os.getcwd()")) # S307 | ||
|
||
|
||
class Class(object): | ||
def eval(self): | ||
print("hi") | ||
|
||
def foo(self): | ||
self.eval() # OK |
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
20 changes: 20 additions & 0 deletions
20
...ff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S307_S307.py.snap
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,20 @@ | ||
--- | ||
source: crates/ruff/src/rules/flake8_bandit/mod.rs | ||
--- | ||
S307.py:3:7: S307 Use of possibly insecure function; consider using `ast.literal_eval` | ||
| | ||
1 | import os | ||
2 | | ||
3 | print(eval("1+1")) # S307 | ||
| ^^^^^^^^^^^ S307 | ||
4 | print(eval("os.getcwd()")) # S307 | ||
| | ||
|
||
S307.py:4:7: S307 Use of possibly insecure function; consider using `ast.literal_eval` | ||
| | ||
3 | print(eval("1+1")) # S307 | ||
4 | print(eval("os.getcwd()")) # S307 | ||
| ^^^^^^^^^^^^^^^^^^^ S307 | ||
| | ||
|
||
|