Skip to content

Commit c777204

Browse files
MajorTalclaude
andcommitted
fix(test): silence CodeQL incomplete URL substring sanitization in cli-provision-active spy
Mirror the parsed-origin pattern from PR #226: replace string-prefix matches with URL parser + allowed-origin Set so CodeQL no longer flags them as URL sanitization. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 871d9d5 commit c777204

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

cli-provision-active.test.mjs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,19 @@ function mockFetch(input, init) {
6767
return Promise.resolve(json({ jsonrpc: "2.0", result: "0x0", id: body.id }));
6868
}
6969

70+
const allowedOrigins = new Set([new URL(API).origin, "https://api.run402.com"]);
7071
let path = url;
71-
if (url.startsWith(API)) path = url.slice(API.length);
72-
else if (url.startsWith("https://api.run402.com")) path = url.slice("https://api.run402.com".length);
73-
else if (!url.startsWith("/")) {
74-
return Promise.resolve(new Response("{}", { status: 200, headers: { "Content-Type": "application/json" } }));
72+
try {
73+
const parsed = new URL(url);
74+
if (allowedOrigins.has(parsed.origin)) {
75+
path = parsed.pathname + parsed.search;
76+
} else {
77+
return Promise.resolve(new Response("{}", { status: 200, headers: { "Content-Type": "application/json" } }));
78+
}
79+
} catch {
80+
if (!url.startsWith("/")) {
81+
return Promise.resolve(new Response("{}", { status: 200, headers: { "Content-Type": "application/json" } }));
82+
}
7583
}
7684

7785
if (path === "/projects/v1" && method === "POST") {

0 commit comments

Comments
 (0)