False negative: narrow argument-shape checks in B508/B509
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start in bandit/plugins/snmp_security_check.py at the B508 and B509 checks, then compare their argument handling with each reproduction case in the issue. Use the omitted, positional, and keyword examples as regression cases; done means B508 consistently evaluates mpModel and B509 evaluates privacy semantically without the reported false negatives or false positive.
Written by the indexing model from the issue text.
Description
Describe the bug
B508 and B509 currently rely on narrow argument-shape checks in bandit/plugins/snmp_security_check.py.
This causes:
- false negatives for insecure SNMP usage when arguments are omitted/positional
- false positives for secure
UsmUserDataconfigs passed via kwargs
Reproduction steps
# Orignal Test Cases:
# SHOULD FAIL
a = CommunityData('public', mpModel=0)
# SHOULD FAIL
insecure = UsmUserData("securityName")
# SHOULD FAIL
auth_no_priv = UsmUserData("securityName","authName")
# SHOULD PASS
less_insecure = UsmUserData("securityName","authName","privName")
---
# False negatives cases:
CommunityData("public") # default mpModel=1 (v2c)
CommunityData("public", 1) # positional mpModel
UsmUserData("securityName", "authName", None) # authNoPriv
---
# False positive (should pass)
UsmUserData(userName="user", authKey="auth", privKey="priv") # authPriv
Expected behavior
- B508 should treat omitted/positional/keyword mpModel consistently.
- B509 should evaluate privacy presence semantically (privKey / equivalent), not only positional arg count.
Bandit version
1.9.1 (Default)
Python version
3.14 (Default)
Additional context
No response
- Dominant language
- Python
- Stars
- 8.4k
- Forks
- 893
- Avg merge
- 6h 52m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PyCQA/bandit
-
Difficulty 1/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Turn off progress bar in CIPossibly taken @silvatechf claimed this 28 days ago. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
`bandit -ii -ll -ii -ll` raises an `IndexError`Possibly taken @botbikamordehai2-sketch claimed this 181 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
NatLabRockies/openstudio-mcp#286 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
intersystems/ipm#1338 ·
Maintainers usually reply within 1 day
-
separate_packages splits imports from the same explicitly configured packagePossibly taken @rahul05ranjan claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
The v0-through-v1 path derives ShutdownDuration its own way, silently overriding a user's definitionOpenv1
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day