Skip to content

suspicious-eval-usage doesn't trigger when expected #5505

@tjkuson

Description

@tjkuson

Using ruff 0.0.276, running ruff check --select S307 scratch.py where scratch.py is

import os

print(eval("1+1"))
print(eval("os.getcwd()"))
print(eval("os.chmod('%s', 0777)" % 'test.txt'))


# A user-defined method named "eval" should not get flagged.
class Test(object):
    def eval(self):
        print("hi")
    def foo(self):
        self.eval()

Test().eval()

flags zero violations. The above Python code is from the Bandit source.

Running bandit flags three violations (as expected).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions