security: validate browser origins at the authenticated websocket proxy
This commit is contained in:
@@ -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);
|
||||
});
|
||||
Reference in New Issue
Block a user