AST parsing hits recursion limit
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bandit |
New
|
Low
|
Unassigned |
Bug Description
The parsing of certain ASTs will hit Python's recursion limit. This happens if AST nodes are nested to a depth greater than "sys.getrecursi
A simple example:
python -c 'print ("+" * 1000) + "1"' > unary.py
bandit unary.py
When this occurs, Bandit will report an exception:
Exception RuntimeError: RuntimeError(
[manager] ERROR Exception occurred when executing tests against /Users/
The start of the traceback with --debug:
[manager] DEBUG Exception string: maximum recursion depth exceeded while calling a Python object
[manager] DEBUG Exception traceback: Traceback (most recent call last):
File "/Users/
score = self._execute_
File "/Users/
score = res.process(data)
File "/Users/
File "/Users/
if self.pre_
File "/Users/
File "/System/
return _format(node)
File "/System/
fields = [(a, _format(b)) for a, b in iter_fields(node)]
File "/System/
fields = [(a, _format(b)) for a, b in iter_fields(node)]
Found when running Bandit against
https:/
This is a cool bug but I'm not sure what to do about it.
Seems like Bandit is probably doing the best it can in this case?