Fix B501 false negative: detect verify=False on Session/Client instances#1407
Open
kimjune01 wants to merge 1 commit intoPyCQA:mainfrom
Open
Fix B501 false negative: detect verify=False on Session/Client instances#1407kimjune01 wants to merge 1 commit intoPyCQA:mainfrom
kimjune01 wants to merge 1 commit intoPyCQA:mainfrom
Conversation
Resolves PyCQA#1394 B501 previously only detected verify=False on module-level calls like requests.get() and httpx.get(), missing equivalent insecure calls on Session/Client instances. Changes: - Detect session.get(..., verify=False) where session is any variable - Detect requests.Session().get(..., verify=False) chained calls - Detect httpx.Client().get(..., verify=False) chained calls - Use HIGH confidence for module-level calls - Use MEDIUM confidence for instance methods (can't statically verify type) Adds examples/requests-session-verify-disabled.py demonstrating the newly detected patterns. All functional tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
B501 only checked module-level calls like
requests.get(verify=False). Instance method calls likesession.get(verify=False)onrequests.Session,httpx.Client, andhttpx.AsyncClientwere not flagged.The qualname matching now handles three patterns:
requests.get(verify=False)— HIGH/HIGH (unchanged)requests.Session().get(verify=False)— HIGH/HIGH (new)session.get(verify=False)— HIGH/MEDIUM (new, lower confidence since we can't statically confirm the type)Test plan
examples/requests-session-verify-disabled.pycovers all patternsverify=TrueFixes #1394