diff options
| author | Dennis Fink | 2026-10-30 20:31:43 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-10-30 20:31:43 +0100 |
| commit | 13a9d9ddce09230017699bc34ac3bf08ed2f84ed (patch) | |
| tree | 3715bd13439a61a8cc6896581811a30b62ac1b16 /tests/tasks/test_sender.py | |
| parent | 8c561e702ed15022b17eae81e4185448c021e1cb (diff) | |
| download | webmentions-ssg-13a9d9ddce09230017699bc34ac3bf08ed2f84ed.tar.gz webmentions-ssg-13a9d9ddce09230017699bc34ac3bf08ed2f84ed.zip | |
fix(core): prevent DNS rebinding in HTTP requests
Pin outbound connections to validated public IP addresses so DNS changes
cannot redirect receiver or sender requests onto private or link-local
networks.
Apply the same protection across redirects, add an overall request
deadline, and keep DNS resolution out of synchronous endpoint form
validation.
Diffstat (limited to '')
| -rw-r--r-- | tests/tasks/test_sender.py | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/tests/tasks/test_sender.py b/tests/tasks/test_sender.py index 0db0d8c..38bae11 100644 --- a/tests/tasks/test_sender.py +++ b/tests/tasks/test_sender.py @@ -1214,43 +1214,6 @@ def test_send_webmention_ignores_unknown_identifier( assert f"Cannot send unknown SentWebmention {identifier}" in caplog.text -def test_ensure_public_request_accepts_public_url( - sender_module: ModuleType, monkeypatch: pytest.MonkeyPatch -) -> None: - is_public_url = Mock(return_value=True) - monkeypatch.setattr(sender_module, "is_public_url", is_public_url) - sender_module.ensure_public_request(httpx.Request("GET", TARGET_URL)) - is_public_url.assert_called_once_with(TARGET_URL) - - -def test_ensure_public_request_rejects_non_public_address( - sender_module: ModuleType, monkeypatch: pytest.MonkeyPatch -) -> None: - is_public_url = Mock(return_value=False) - monkeypatch.setattr(sender_module, "is_public_url", is_public_url) - with pytest.raises( - sender_module.PermanentSenderError, - match="Request resolves to a non-public address", - ): - sender_module.ensure_public_request(httpx.Request("GET", TARGET_URL)) - is_public_url.assert_called_once_with(TARGET_URL) - - -def test_ensure_public_request_maps_dns_failure_to_temporary_error( - sender_module: ModuleType, monkeypatch: pytest.MonkeyPatch -) -> None: - is_public_url = Mock( - side_effect=AddressResolutionError("Could not resolve hostname") - ) - monkeypatch.setattr(sender_module, "is_public_url", is_public_url) - with pytest.raises( - sender_module.TemporarySenderError, - match="Request hostname could not be resolved", - ): - sender_module.ensure_public_request(httpx.Request("GET", TARGET_URL)) - is_public_url.assert_called_once_with(TARGET_URL) - - def test_resolve_endpoint_rejects_invalid_url( sender_module: ModuleType, monkeypatch: pytest.MonkeyPatch ) -> None: |
