Reports are taken only as application/json (closes #126)
check / check (push) Waiting to run

A page on another origin can POST text/plain or a form without a CORS
preflight, so its visitors' browsers could store reports although the
server sends no CORS headers. decodeJSON now refuses a request whose
Content-Type is not application/json (parameters such as charset
allowed), and the report handler answers it 415 with the usual error
body, storing nothing. A JSON POST waits for the preflight, which only
an origin in CORS_ALLOWED_ORIGINS passes; the page already sends
application/json.

Model: opus-5-5
This commit is contained in:
2026-10-14 09:48:58 +00:00
parent b1eefe0c29
commit 521cdcb343
6 changed files with 152 additions and 8 deletions
+1
View File
@@ -66,6 +66,7 @@ func TestReportsAreRateLimited(t *testing.T) {
http.MethodPost, "/api/v1/reports",
strings.NewReader(`{"clientId":"c1","hosts":[]}`),
)
req.Header.Set("Content-Type", "application/json")
srv.ServeHTTP(rec, req)
return rec.Code