From ddae41b7c9f31f8a6c0100a3a4ee15f6c55f57f0 Mon Sep 17 00:00:00 2001 From: 0xMarcio Date: Thu, 22 Oct 2026 21:54:31 +0200 Subject: [PATCH] Replace unreadable captures instead of reusing them --- scripts/archive_pocs.py | 4 ++++ tests/test_archive_pocs.py | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/scripts/archive_pocs.py b/scripts/archive_pocs.py index 7e236133a01..0e66612ce1e 100644 --- a/scripts/archive_pocs.py +++ b/scripts/archive_pocs.py @@ -383,6 +383,10 @@ def verify_snapshot(snap: dict, original: str, expected_blobs=(), repo_id=None, return False snap['verified_at'] = now() return True + except ArchiveError as exc: + if str(exc) in {'response-too-large', 'unsupported-response-encoding', 'invalid-compressed-response'}: + return False + raise except error.HTTPError as exc: status = exc.code retry = exc.headers.get('Retry-After', '') diff --git a/tests/test_archive_pocs.py b/tests/test_archive_pocs.py index 7c656875a09..d40e517cd10 100644 --- a/tests/test_archive_pocs.py +++ b/tests/test_archive_pocs.py @@ -503,6 +503,21 @@ class ArchiveTests(unittest.TestCase): with self.assertRaisesRegex(archive.ArchiveError, 'invalid-compressed-response'): archive.response_bytes(response, 1000) + def test_corrupt_replay_is_replaced_instead_of_reusing_the_failed_capture(self): + snap = snapshot() + response = io.BytesIO(gzip.compress(b'poc')[:-8]) + response.headers = {'Content-Encoding': 'gzip'} + response.status = 200 + response.url = snap['url'].replace(snap['timestamp'] + '/', snap['timestamp'] + 'id_/') + opener = MagicMock() + opener.open.return_value = response + row = {**self.target, 'candidate': snap} + with patch.object(archive.request, 'build_opener', return_value=opener): + archive.verify_candidate(row) + self.assertTrue(row['bad_capture']) + self.assertNotIn('candidate', row) + self.assertFalse(archive.valid_snapshot(row)) + if __name__ == '__main__': unittest.main()