security: validate browser origins at the authenticated websocket proxy

This commit is contained in:
2026-10-20 15:48:02 +01:00
parent c6695e5e90
commit 1cf5156c77
4 changed files with 40 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { sameOriginUpgrade } from "../src/proxySecurity.js";
test("the authenticated proxy checks Origin before discarding it upstream", () => {
assert.equal(sameOriginUpgrade("http://localhost:8095", "localhost:8095"), true);
assert.equal(sameOriginUpgrade("https://pipelines.example", "pipelines.example"), true);
assert.equal(sameOriginUpgrade("https://untrusted.example", "pipelines.example"), false);
assert.equal(sameOriginUpgrade("http://localhost:8094", "localhost:8095"), false);
assert.equal(sameOriginUpgrade("null", "localhost:8095"), false);
assert.equal(sameOriginUpgrade("file:///report.html", "localhost:8095"), false);
assert.equal(sameOriginUpgrade(undefined, "localhost:8095"), true);
});