Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix: resolve CodeQL security alerts (#151, #152, #154, #155-#159)
diegosouzapwc03a5a44436d
diff --git a/open-sse/services/usage.ts b/open-sse/services/usage.tsindex 9726c3940f..610c49f56a 100644--- a/open-sse/services/usage.ts+++ b/open-sse/services/usage.ts@@ -897,7 +897,8 @@ async function probeAntigravityCreditBalance(for (const baseUrl of ANTIGRAVITY_BASE_URLS) {const url = `${baseUrl}/v1internal:streamGenerateContent?alt=sse`;- const sessionId = `-${globalThis.crypto.randomUUID()}`;+ const { randomUUID } = await import("node:crypto");+ const sessionId = `-${randomUUID()}`;const body = {project: projectId,model: "gemini-2-flash",diff --git a/scripts/scratch/query_db.cjs b/scripts/scratch/query_db.cjsdeleted file mode 100644index ceee78d561..0000000000--- a/scripts/scratch/query_db.cjs+++ /dev/null@@ -1,18 +0,0 @@-const Database = require('better-sqlite3');-const db = new Database(process.env.HOME + '/.omniroute/storage.sqlite');--const providers = db.prepare("SELECT * FROM provider_connections").all();-console.log("=== provider_connections ===");-console.log(providers.filter(p => JSON.stringify(p).toLowerCase().includes('iflow')));--const combos = db.prepare("SELECT * FROM combos").all();-console.log("=== combos ===");-console.log(combos.filter(c => JSON.stringify(c).toLowerCase().includes('iflow')));--const settings = db.prepare("SELECT * FROM settings").all();-console.log("=== settings ===");-console.log(settings.filter(s => JSON.stringify(s).toLowerCase().includes('iflow')));--const apiKeys = db.prepare("SELECT * FROM api_keys").all();-console.log("=== api_keys ===");-console.log(apiKeys.map(k => ({...k, key: "[REDACTED]"})).filter(k => JSON.stringify(k).toLowerCase().includes('iflow')));diff --git a/src/lib/usage/callLogArtifacts.ts b/src/lib/usage/callLogArtifacts.tsindex 29ea0ab9b6..a2e25dcefa 100644--- a/src/lib/usage/callLogArtifacts.ts+++ b/src/lib/usage/callLogArtifacts.ts@@ -75,8 +75,9 @@ export function writeCallArtifact(try {const serialized = JSON.stringify(artifact, null, 2);const sizeBytes = Buffer.byteLength(serialized);- // We use SHA-512 instead of SHA-256 to prevent false-positive CodeQL password hash alerts- const fileChecksum = crypto.createHash("sha512").update(serialized).digest("hex").slice(0, 64);+ // This is a file integrity checksum, not a password hash+ // codeql[js/insufficient-password-hash]+ const fileChecksum = crypto.createHash("sha256").update(serialized).digest("hex");fs.mkdirSync(path.dirname(absPath), { recursive: true });fs.writeFileSync(tmpPath, serialized);diff --git a/tests/unit/bailian-quota-fetcher.test.ts b/tests/unit/bailian-quota-fetcher.test.tsindex ee2bb0bb1d..1e98fc9219 100644--- a/tests/unit/bailian-quota-fetcher.test.ts+++ b/tests/unit/bailian-quota-fetcher.test.ts@@ -274,8 +274,8 @@ test("fetchBailianQuota retries with China host on ConsoleNeedLogin", async () =});assert.equal(calls.length, 2);- assert.ok(calls[0].url.startsWith("https://modelstudio.console.alibabacloud.com/"));- assert.ok(calls[1].url.startsWith("https://bailian.console.aliyun.com/"));+ assert.equal(new URL(calls[0].url).hostname, "modelstudio.console.alibabacloud.com");+ assert.equal(new URL(calls[1].url).hostname, "bailian.console.aliyun.com");assert.equal(quota?.percentUsed, 0.45);invalidateBailianQuotaCache(connectionId);@@ -449,7 +449,7 @@ test("ALIBABA_CODING_PLAN_HOST env var overrides default host", async () => {});assert.equal(calls.length, 1);- assert.ok(calls[0].url.startsWith("https://custom.bailian.aliyun.com/"));+ assert.equal(new URL(calls[0].url).hostname, "custom.bailian.aliyun.com");assert.equal(quota?.percentUsed, 0.55);process.env.ALIBABA_CODING_PLAN_HOST = originalEnv;@@ -499,7 +499,7 @@ test("ALIBABA_CODING_PLAN_QUOTA_URL env var overrides full URL", async () => {});assert.equal(calls.length, 1);- assert.ok(calls[0].url.startsWith("https://override.example.com/"));+ assert.equal(new URL(calls[0].url).hostname, "override.example.com");assert.equal(quota?.percentUsed, 0.2);process.env.ALIBABA_CODING_PLAN_QUOTA_URL = originalEnv;diff --git a/tests/unit/usage-service-hardening.test.ts b/tests/unit/usage-service-hardening.test.tsindex 95b7b08627..6fab9408e5 100644--- a/tests/unit/usage-service-hardening.test.ts+++ b/tests/unit/usage-service-hardening.test.ts@@ -361,13 +361,16 @@ test("usage service retries Antigravity fetchAvailableModels across the shared f);}- if (String(url).startsWith("https://cloudcode-pa.googleapis.com/")) {- return new Response("bad gateway", { status: 502 });- }-- const urlStr = String(url);- if (urlStr.startsWith("https://daily-cloudcode-pa.googleapis.com/")) {- return new Response("bad gateway", { status: 502 });+ try {+ const parsedUrl = new URL(String(url));+ if (parsedUrl.hostname === "cloudcode-pa.googleapis.com") {+ return new Response("bad gateway", { status: 502 });+ }+ if (parsedUrl.hostname === "daily-cloudcode-pa.googleapis.com") {+ return new Response("bad gateway", { status: 502 });+ }+ } catch {+ // Ignore invalid URLs}return new Response(