feat: Pin webmention connections; re-send when responses change (v2.7.2)
- Connect to the address that passed the SSRF check (Host header and SNI carry the hostname, so TLS still verifies it), closing the DNS rebinding gap (spec 4.5). The webmention POST uses the same path. - Treat a change in the responses a note shows as an update and re-send its webmentions (spec 3.1.4), from validation and from admin moderation. Unchanged re-validations send nothing, so there is no ping-pong. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
51f711ea4a
commit
0640730416
10 files changed
+315
-26
No files matched your search
@@ -37,16 +37,18 @@ def test_worker_sends_queued_webmention(app):
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
def target_site(request):
|
||||
return httpx.Response(200, headers={"Link": '</wm>; rel="webmention"'})
|
||||
posts = []
|
||||
|
||||
accepted = MagicMock(status_code=202, text="")
|
||||
def target_site(request):
|
||||
if request.method == "POST":
|
||||
posts.append((request.headers["host"], request.url.path, request.content))
|
||||
return httpx.Response(202)
|
||||
return httpx.Response(200, headers={"Link": '</wm>; rel="webmention"'})
|
||||
|
||||
worker = WebmentionWorker(app, db_path=db_path, site_url=app.config["SITE_URL"],
|
||||
poll_interval=0.05)
|
||||
with patch("starpunk.webmention_ssrf.socket.getaddrinfo", return_value=PUBLIC), \
|
||||
patch("starpunk.webmention_ssrf.TRANSPORT", httpx.MockTransport(target_site)), \
|
||||
patch("starpunk.webmention_worker.httpx.post", return_value=accepted) as post:
|
||||
patch("starpunk.webmention_ssrf.TRANSPORT", httpx.MockTransport(target_site)):
|
||||
worker.start()
|
||||
try:
|
||||
def status():
|
||||
@@ -56,8 +58,8 @@ def test_worker_sends_queued_webmention(app):
|
||||
return row
|
||||
assert _wait_for(lambda: status()[0] != "pending"), status()
|
||||
assert status() == ("sent", None)
|
||||
post.assert_called_once()
|
||||
assert post.call_args.args[0] == "https://example.org/wm"
|
||||
assert [(h, p) for h, p, _ in posts] == [("example.org", "/wm")]
|
||||
assert b"source=" in posts[0][2] and b"target=" in posts[0][2]
|
||||
finally:
|
||||
worker.stop()
|
||||
worker.join(timeout=2)
|
||||
|
||||
Reference in new issue
Block a user