Skip to content

IndexError: list index out of range while scanning cpython #1141

@ericwb

Description

@ericwb

Describe the bug

Received a IndexError: list index out of range while scanning the source code contents of the Python cpython library.

Reproduction steps

1. `git clone https://github.com/python/cpython`
2. Run `bandit -r cpython`
3. Notice the IndexError at the beginning of the output.



[main]	INFO	running on Python 3.12.2
Working... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸━━━━━━━━━━━  72% 0:00:26[tester]	ERROR	Bandit internal error running: start_process_with_partial_path on file ../cpython/Lib/test/test_subprocess.py at line 180: list index out of rangeTraceback (most recent call last):
  File "/Users/ericwb/workspace/bandit/bandit/core/tester.py", line 51, in run_tests
    result = test(context, test._config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ericwb/workspace/bandit/bandit/plugins/injection_shell.py", line 687, in start_process_with_partial_path
    node = node.elts[0]
           ~~~~~~~~~^^^
IndexError: list index out of range

[tester]	ERROR	Bandit internal error running: start_process_with_partial_path on file ../cpython/Lib/test/test_subprocess.py at line 184: list index out of rangeTraceback (most recent call last):
  File "/Users/ericwb/workspace/bandit/bandit/core/tester.py", line 51, in run_tests
    result = test(context, test._config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ericwb/workspace/bandit/bandit/plugins/injection_shell.py", line 687, in start_process_with_partial_path
    node = node.elts[0]
           ~~~~~~~~~^^^
IndexError: list index out of range


### Expected behavior

The code should be more robust to avoid exceptions and errors.

### Bandit version

1.7.7 (Default)

### Python version

3.12 (Default)

### Additional context

_No response_

Metadata

Metadata

Assignees

No one assigned

    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