test(docker): cover the per-URL crawler_configs PDF SSRF guard - #2158
Merged
Conversation
handle_crawl_request builds the per-URL config list on a separate branch from the top-level config, so the url_validator wiring has to be repeated there. #2150 fixed that, but nothing exercised it — the existing pairing tests only go through the top-level path, leaving the guard free to be dropped by a future refactor without a red test. Verified by mutation: removing the guard from api.py fails this test and nothing else. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Follow-up to #2150 (test only, no behaviour change).
Why
handle_crawl_requestbuilds the per-URL config list on a separate branch from the top-level config, so theurl_validatorwiring has to be repeated there. #2150 fixed that gap, but nothing in the suite exercises it — the existing pairing tests only go through the top-level path. The guard could be dropped by a future refactor and no test would go red.crawler_configsis a public per-URL field on/crawl, so an unvetted PDF strategy sent that way would do an unvalidated download of whatever the request names.What
One test in
tests/test_docker_pdf_crawler_pairing.py: sends a PDF strategy viacrawler_configs(top-level config left clean, two URLs so the config-list branch engages) and asserts every per-URL PDF strategy reachingarun_manycarriesvalidate_url_destination.It also asserts exactly one PDF strategy survives deserialization — without that, a future change that drops the strategy would make the loop pass vacuously and the test would protect nothing.
pool_mockgains anarun_manystub, which the config-list path needs.Testing
tests/test_docker_pdf_crawler_pairing.py+tests/test_issue_2127_docker_pdf.py: 9 passed.deploy/docker/api.pyfails this test and nothing else, so it is genuinely load-bearing.cc @SohamKukreti