Skip to content

fix: clamp severity/confidence index to prevent IndexError (closes #1423)#1429

Open
botbikamordehai2-sketch wants to merge 2 commits into
PyCQA:mainfrom
botbikamordehai2-sketch:fix/issue-1423-1779960500
Open

fix: clamp severity/confidence index to prevent IndexError (closes #1423)#1429
botbikamordehai2-sketch wants to merge 2 commits into
PyCQA:mainfrom
botbikamordehai2-sketch:fix/issue-1423-1779960500

Conversation

@botbikamordehai2-sketch

Copy link
Copy Markdown

What

When -ii -ll is specified multiple times on the command line (e.g., bandit -ii -ll -ii -ll), args.severity and args.confidence accumulate counts beyond the valid index range of constants.RANKING, causing an IndexError.

Fix

Clamp the severity and confidence values to the maximum valid index in constants.RANKING before using them as indices. This ensures that specifying -i or -l more times than there are ranking levels defaults to the highest level rather than raising an error.

Closes #1423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bandit -ii -ll -ii -ll raises an IndexError

1 participant