improve: add granular error handling and expand WAF detection#2931
Open
mohamedsolaiman wants to merge 1 commit intosherlock-project:masterfrom
Open
improve: add granular error handling and expand WAF detection#2931mohamedsolaiman wants to merge 1 commit intosherlock-project:masterfrom
mohamedsolaiman wants to merge 1 commit intosherlock-project:masterfrom
Conversation
get_response() improvements:
- Add SSLError as a distinct exception handler before ConnectionError,
providing clearer "SSL Error" context instead of the generic
"Error Connecting" message for TLS/certificate failures.
- Add ChunkedEncodingError handling for incomplete chunked responses
from servers, which previously fell through to "Unknown Error".
- Add ContentDecodingError handling for gzip/deflate decompression
failures, which previously fell through to "Unknown Error".
WAF detection improvements:
- Add case-insensitive WAF fingerprint matching for patterns that may
vary in capitalization across different WAF challenge pages.
- Add fingerprints for Cloudflare browser verification, Turnstile, and
challenge page titles ("Just a moment...").
- Add fingerprint for generic WAF captcha pages.
- These help reduce false positives from sites that serve WAF challenge
pages with varying text formatting.
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
Improves error handling granularity in
get_response()and expands WAF (Web Application Firewall) detection to reduce false positives from WAF-blocked responses.Changes to
get_response()Added
SSLErrorhandlingrequests.exceptions.SSLErroris a subclass ofConnectionErrorbut represents a distinctly different problem (TLS certificate validation failure vs network connectivity)ConnectionErrorcatch since it is a more specific subclassAdded
ChunkedEncodingErrorhandlingrequests.exceptions.ChunkedEncodingErroroccurs when a server sends an incomplete chunked transfer encoding responseAdded
ContentDecodingErrorhandlingrequests.exceptions.ContentDecodingErroroccurs when response body decompression fails (e.g., corrupted gzip/deflate content)Changes to WAF Detection
Added case-insensitive WAF fingerprint matching
WAFHitMsgsCaseInsensitivelist for patterns that need case-insensitive matchingNew WAF fingerprints:
cf-browser-verification: Cloudflare browser verification classjust a moment...: Cloudflare interstitial challenge page title (e.g., "Just a moment...")enable javascript and cookies to continue: Cloudflare challenge instruction textattentionrequired: Cloudflare Turnstile challenge attributewhy do i have to complete a captcha: Generic WAF captcha explanation textThese fingerprints help catch WAF challenge pages that were previously missed, reducing false positives where Sherlock would incorrectly report a username as "Claimed" when the response was actually a WAF block page.
Testing