From 85972b73ea32f438cc1866607b1cbc8675640af9 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Tue, 13 Jan 2026 21:49:08 +0800 Subject: [PATCH] feat: update CSRF protection logic and enhance GPU detection method; improve i18n for hook wizard templates --- ccw/src/core/auth/csrf-middleware.ts | 4 +++- .../core/routes/codexlens/config-handlers.ts | 21 +++++++++++-------- ccw/src/templates/dashboard-js/i18n.js | 18 ++++++++++++++-- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/ccw/src/core/auth/csrf-middleware.ts b/ccw/src/core/auth/csrf-middleware.ts index 119d1fba..5c0a6084 100644 --- a/ccw/src/core/auth/csrf-middleware.ts +++ b/ccw/src/core/auth/csrf-middleware.ts @@ -113,7 +113,9 @@ export async function csrfValidation(ctx: CsrfMiddlewareContext): Promise = []; if (process.platform === 'win32') { - // Windows: Use WMIC to get GPU info + // Windows: Use PowerShell Get-CimInstance (wmic is deprecated in Windows 11) try { const { execSync } = await import('child_process'); - const wmicOutput = execSync('wmic path win32_VideoController get name', { - encoding: 'utf-8', - timeout: EXEC_TIMEOUTS.SYSTEM_INFO, - stdio: ['pipe', 'pipe', 'pipe'] - }); + const psOutput = execSync( + 'powershell -NoProfile -Command "(Get-CimInstance Win32_VideoController).Name"', + { + encoding: 'utf-8', + timeout: EXEC_TIMEOUTS.SYSTEM_INFO, + stdio: ['pipe', 'pipe', 'pipe'] + } + ); - const lines = wmicOutput.split('\n') + const lines = psOutput.split('\n') .map(line => line.trim()) - .filter(line => line && line !== 'Name'); + .filter(line => line); lines.forEach((name, index) => { if (name) { @@ -476,7 +479,7 @@ export async function handleCodexLensConfigRoutes(ctx: RouteContext): Promise