diff --git a/tests/discovery/test_zoomeyesearch.py b/tests/discovery/test_zoomeyesearch.py index db1e1a37..d1b9c4dd 100644 --- a/tests/discovery/test_zoomeyesearch.py +++ b/tests/discovery/test_zoomeyesearch.py @@ -181,11 +181,15 @@ async def test_numbered_pages_keep_a_stable_size_and_slice_the_final_page(monkey @pytest.mark.asyncio -async def test_early_malformed_rows_and_later_valid_evidence_are_partial(monkeypatch: pytest.MonkeyPatch) -> None: +@pytest.mark.parametrize('malformed_match', [7, {'url': ['https://api.example.com']}]) +async def test_early_malformed_rows_and_later_valid_evidence_are_partial( + monkeypatch: pytest.MonkeyPatch, + malformed_match: Any, +) -> None: monkeypatch.setattr(zoomeyesearch.Core, 'zoomeye_key', staticmethod(lambda: 'test-key')) monkeypatch.setattr(zoomeyesearch.SearchZoomEye, 'PAGE_SIZE', 1) responses = [ - FetcherResponse({'code': 60000, 'total': 2, 'data': [7]}, 200, {}), + FetcherResponse({'code': 60000, 'total': 2, 'data': [malformed_match]}, 200, {}), FetcherResponse({'code': 60000, 'total': 2, 'data': [{'hostname': 'api.example.com'}]}, 200, {}), ] diff --git a/theHarvester/discovery/zoomeyesearch.py b/theHarvester/discovery/zoomeyesearch.py index 055c9e7c..fc554989 100644 --- a/theHarvester/discovery/zoomeyesearch.py +++ b/theHarvester/discovery/zoomeyesearch.py @@ -167,13 +167,16 @@ class SearchZoomEye: elif (hostname := normalize_scoped_hostname(value, self.target)) and hostname != self.target: hostnames.add(hostname) - if raw_url := match.get('url'): - if normalized_url := self._normalize_url(raw_url): + raw_url = match.get('url') + if raw_url is not None: + if not isinstance(raw_url, str): + malformed = True + elif normalized_url := self._normalize_url(raw_url): urls.add(normalized_url) if url_hostname := normalize_scoped_hostname(urlsplit(normalized_url).hostname, self.target): if url_hostname != self.target: hostnames.add(url_hostname) - elif isinstance(raw_url, str): + else: malformed = True text_values: list[str] = []