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).