mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
test(security): parse hostname instead of URL substring match
Replace `result.url.includes("poe.com")` / `.includes("doubao.com")` with a
parsed `new URL(result.url).hostname` check that accepts the exact host or a
legitimate subdomain (`.endsWith(".poe.com")`). The substring form also matches
hostile URLs like `https://evil.com/?x=poe.com`, which CodeQL flags as
js/incomplete-url-substring-sanitization (2 high-severity alerts on PR #2930).
This strengthens the assertion rather than masking it — the executors build
`https://www.poe.com` / `https://www.doubao.com`, both still satisfied.
This commit is contained in:
@@ -20,7 +20,11 @@ describe("DoubaoWebExecutor", () => {
|
||||
signal: null,
|
||||
});
|
||||
assert.ok(result.response instanceof Response);
|
||||
assert.ok(result.url.includes("doubao.com"));
|
||||
// Parse the host instead of substring-matching the URL: a bare
|
||||
// `.includes("doubao.com")` would also accept hostile URLs like
|
||||
// `https://evil.com/?x=doubao.com` (CodeQL js/incomplete-url-substring-sanitization).
|
||||
const host = new URL(result.url).hostname;
|
||||
assert.ok(host === "doubao.com" || host.endsWith(".doubao.com"), `unexpected host: ${host}`);
|
||||
} catch {
|
||||
// Network error expected
|
||||
}
|
||||
|
||||
@@ -20,7 +20,11 @@ describe("PoeWebExecutor", () => {
|
||||
signal: null,
|
||||
});
|
||||
assert.ok(result.response instanceof Response);
|
||||
assert.ok(result.url.includes("poe.com"));
|
||||
// Parse the host instead of substring-matching the URL: a bare
|
||||
// `.includes("poe.com")` would also accept hostile URLs like
|
||||
// `https://evil.com/?x=poe.com` (CodeQL js/incomplete-url-substring-sanitization).
|
||||
const host = new URL(result.url).hostname;
|
||||
assert.ok(host === "poe.com" || host.endsWith(".poe.com"), `unexpected host: ${host}`);
|
||||
} catch {
|
||||
// Network error expected
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user