From 00df10c29a2660a604187b35e04d3a3c72581c0a Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Wed, 18 Mar 2026 17:16:30 -0300 Subject: [PATCH] "fix: resolved UI combo setting schema strip (#458)" "fix: safe crypto fallback for MITM on windows (#456)" --- src/shared/utils/machineId.ts | 34 +++++++++++++++++++------------- src/shared/validation/schemas.ts | 11 ++++++++++- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/shared/utils/machineId.ts b/src/shared/utils/machineId.ts index ef405693c3..02a2fff9f1 100644 --- a/src/shared/utils/machineId.ts +++ b/src/shared/utils/machineId.ts @@ -23,13 +23,16 @@ export async function getConsistentMachineId(salt = null) { } catch (error) { console.log("Error getting machine ID:", error); // Fallback to random ID if node-machine-id fails - return crypto.randomUUID - ? crypto.randomUUID() - : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { - const r = (Math.random() * 16) | 0; - const v = c == "x" ? r : (r & 0x3) | 0x8; - return v.toString(16); - }); + try { + const cryptoFallback = await import("crypto"); + return cryptoFallback.randomUUID(); + } catch { + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { + const r = (Math.random() * 16) | 0; + const v = c == "x" ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); + } } } @@ -44,13 +47,16 @@ export async function getRawMachineId() { } catch (error) { console.log("Error getting raw machine ID:", error); // Fallback to random ID if node-machine-id fails - return crypto.randomUUID - ? crypto.randomUUID() - : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { - const r = (Math.random() * 16) | 0; - const v = c == "x" ? r : (r & 0x3) | 0x8; - return v.toString(16); - }); + try { + const cryptoFallback = await import("crypto"); + return cryptoFallback.randomUUID(); + } catch { + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { + const r = (Math.random() * 16) | 0; + const v = c == "x" ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); + } } } diff --git a/src/shared/validation/schemas.ts b/src/shared/validation/schemas.ts index 9dd115e684..bc63a9aca1 100644 --- a/src/shared/validation/schemas.ts +++ b/src/shared/validation/schemas.ts @@ -80,6 +80,9 @@ export const createComboSchema = z.object({ strategy: comboStrategySchema.optional().default("priority"), config: comboConfigSchema, allowedProviders: z.array(z.string().max(200)).optional(), + system_message: z.string().max(50000).optional(), + tool_filter_regex: z.string().max(1000).optional(), + context_cache_protection: z.boolean().optional(), }); // ──── Auto-Combo Schemas ──── @@ -813,6 +816,9 @@ export const updateComboSchema = z config: comboRuntimeConfigSchema.optional(), isActive: z.boolean().optional(), allowedProviders: z.array(z.string().max(200)).optional(), + system_message: z.string().max(50000).optional(), + tool_filter_regex: z.string().max(1000).optional(), + context_cache_protection: z.boolean().optional(), }) .superRefine((value, ctx) => { if ( @@ -821,7 +827,10 @@ export const updateComboSchema = z value.strategy === undefined && value.config === undefined && value.isActive === undefined && - value.allowedProviders === undefined + value.allowedProviders === undefined && + value.system_message === undefined && + value.tool_filter_regex === undefined && + value.context_cache_protection === undefined ) { ctx.addIssue({ code: z.ZodIssueCode.custom,