mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-20 17:13:49 +00:00
fix(security): harden URL and HTML sanitization
This commit is contained in:
6 files changed
+9
-6
No files matched your search
@@ -151,7 +151,7 @@ describe("discord interactions", () => {
|
||||
const url = String(input);
|
||||
if (url.includes("/callback")) {
|
||||
order.push(`callback:${(JSON.parse(String(init?.body)) as { type: number }).type}`);
|
||||
} else if (url.includes("api.github.com")) {
|
||||
} else if (new URL(url).hostname === "api.github.com") {
|
||||
order.push("github");
|
||||
return new Response(
|
||||
JSON.stringify({ html_url: "https://github.com/o/r/issues/7#c", user: { login: "a" } }),
|
||||
@@ -203,7 +203,7 @@ describe("discord interactions", () => {
|
||||
components: [{ components: [{ custom_id: "body", value: "hello" }] }],
|
||||
},
|
||||
});
|
||||
expect(calls.some((u) => u.includes("api.github.com"))).toBe(false);
|
||||
expect(calls.some((u) => new URL(u).hostname === "api.github.com")).toBe(false);
|
||||
});
|
||||
|
||||
it("refuses to save an edit over changes made on GitHub after the modal opened", async () => {
|
||||
|
||||
@@ -657,7 +657,7 @@ describe("dispatchEvent fallback routing", () => {
|
||||
const sent: string[] = [];
|
||||
const bodies: string[] = [];
|
||||
mockFetch((url, init) => {
|
||||
if (url.includes("api.github.com") && url.includes("/jobs")) {
|
||||
if (new URL(url).hostname === "api.github.com" && url.includes("/jobs")) {
|
||||
return Response.json({
|
||||
jobs: [
|
||||
{
|
||||
|
||||
@@ -330,7 +330,7 @@ describe("telegram-commands refusals and whitespace", () => {
|
||||
let replies = 0;
|
||||
let github = 0;
|
||||
mockFetch((url) => {
|
||||
if (url.includes("api.github.com")) github++;
|
||||
if (new URL(url).hostname === "api.github.com") github++;
|
||||
replies++;
|
||||
return new Response(JSON.stringify({ ok: false, description: "Bad Gateway" }), {
|
||||
status: 502,
|
||||
|
||||
Reference in new issue
Block a user