From fabaea3886a3abdff2f7d65f3ee98e7a26f1c2d7 Mon Sep 17 00:00:00 2001 From: NotoriousRebel <36310667+NotoriousRebel@users.noreply.github.com> Date: Wed, 26 Aug 2026 16:33:58 -0400 Subject: [PATCH] fix: classify proxied response stream failures --- tests/test_main.py | 20 ++++++++++++++++++-- theHarvester/lib/core.py | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index acd201b0..20687614 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -3638,9 +3638,25 @@ async def test_shodan_action_records_configured_proxy_transport_failure(monkeypa async def get_urls(self) -> set[str]: return set() + class FailingContent: + async def iter_any(self): + raise OSError('proxy disconnected while streaming') + yield b'' + + class FailingResponse: + status = 200 + headers: dict[str, str] = {} + content = FailingContent() + + async def __aenter__(self): + return self + + async def __aexit__(self, *_args: object) -> None: + return None + class FailingSession: - def request(self, *_args: object, **_kwargs: object) -> object: - raise OSError('proxy endpoint unavailable') + def request(self, *_args: object, **_kwargs: object) -> FailingResponse: + return FailingResponse() class FailedShodan: error_type = None diff --git a/theHarvester/lib/core.py b/theHarvester/lib/core.py index b51df23d..93e495e7 100644 --- a/theHarvester/lib/core.py +++ b/theHarvester/lib/core.py @@ -106,6 +106,7 @@ async def _bounded_response_chunks( except ResponseStreamError: raise except (aiohttp.ClientError, TimeoutError, OSError) as error: + _mark_proxy_transport_failed() raise ResponseStreamError('transport-error') from error