mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
feat: update CSRF protection logic and enhance GPU detection method; improve i18n for hook wizard templates
This commit is contained in:
@@ -113,7 +113,9 @@ export async function csrfValidation(ctx: CsrfMiddlewareContext): Promise<boolea
|
|||||||
const { pathname, req, res } = ctx;
|
const { pathname, req, res } = ctx;
|
||||||
|
|
||||||
if (!pathname.startsWith('/api/')) return true;
|
if (!pathname.startsWith('/api/')) return true;
|
||||||
if (envFlagEnabled('CCW_DISABLE_CSRF')) return true;
|
// CSRF is disabled by default for local deployment scenarios.
|
||||||
|
// Set CCW_ENABLE_CSRF=1 to enable CSRF protection.
|
||||||
|
if (!envFlagEnabled('CCW_ENABLE_CSRF')) return true;
|
||||||
|
|
||||||
const method = (req.method || 'GET').toUpperCase();
|
const method = (req.method || 'GET').toUpperCase();
|
||||||
if (!['POST', 'PUT', 'PATCH', 'DELETE'].includes(method)) return true;
|
if (!['POST', 'PUT', 'PATCH', 'DELETE'].includes(method)) return true;
|
||||||
|
|||||||
@@ -451,18 +451,21 @@ export async function handleCodexLensConfigRoutes(ctx: RouteContext): Promise<bo
|
|||||||
const devices: Array<{ name: string; type: string; index: number }> = [];
|
const devices: Array<{ name: string; type: string; index: number }> = [];
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
// Windows: Use WMIC to get GPU info
|
// Windows: Use PowerShell Get-CimInstance (wmic is deprecated in Windows 11)
|
||||||
try {
|
try {
|
||||||
const { execSync } = await import('child_process');
|
const { execSync } = await import('child_process');
|
||||||
const wmicOutput = execSync('wmic path win32_VideoController get name', {
|
const psOutput = execSync(
|
||||||
encoding: 'utf-8',
|
'powershell -NoProfile -Command "(Get-CimInstance Win32_VideoController).Name"',
|
||||||
timeout: EXEC_TIMEOUTS.SYSTEM_INFO,
|
{
|
||||||
stdio: ['pipe', 'pipe', 'pipe']
|
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())
|
.map(line => line.trim())
|
||||||
.filter(line => line && line !== 'Name');
|
.filter(line => line);
|
||||||
|
|
||||||
lines.forEach((name, index) => {
|
lines.forEach((name, index) => {
|
||||||
if (name) {
|
if (name) {
|
||||||
@@ -476,7 +479,7 @@ export async function handleCodexLensConfigRoutes(ctx: RouteContext): Promise<bo
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('[CodexLens] WMIC GPU detection failed:', (e as Error).message);
|
console.warn('[CodexLens] PowerShell GPU detection failed:', (e as Error).message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Linux/Mac: Try nvidia-smi for NVIDIA GPUs
|
// Linux/Mac: Try nvidia-smi for NVIDIA GPUs
|
||||||
|
|||||||
@@ -1092,7 +1092,14 @@ const i18n = {
|
|||||||
|
|
||||||
// Hook Wizard Templates
|
// Hook Wizard Templates
|
||||||
'hook.wizard.memoryUpdate': 'Memory Update Hook',
|
'hook.wizard.memoryUpdate': 'Memory Update Hook',
|
||||||
'hook.wizard.memoryUpdateDesc': 'Automatically update CLAUDE.md documentation based on code changes',
|
'hook.wizard.memoryUpdateDesc': 'Queue-based CLAUDE.md updates with configurable threshold and timeout',
|
||||||
|
'hook.wizard.queueBasedUpdate': 'Queue-Based Update',
|
||||||
|
'hook.wizard.queueBasedUpdateDesc': 'Batch updates when threshold reached or timeout expires',
|
||||||
|
'hook.wizard.thresholdPaths': 'Threshold (paths)',
|
||||||
|
'hook.wizard.thresholdPathsDesc': 'Number of paths to trigger batch update',
|
||||||
|
'hook.wizard.timeoutSeconds': 'Timeout (seconds)',
|
||||||
|
'hook.wizard.timeoutSecondsDesc': 'Auto-flush queue after this time',
|
||||||
|
// Legacy keys (kept for compatibility)
|
||||||
'hook.wizard.onSessionEnd': 'On Session End',
|
'hook.wizard.onSessionEnd': 'On Session End',
|
||||||
'hook.wizard.onSessionEndDesc': 'Update documentation when Claude session ends',
|
'hook.wizard.onSessionEndDesc': 'Update documentation when Claude session ends',
|
||||||
'hook.wizard.periodicUpdate': 'Periodic Update',
|
'hook.wizard.periodicUpdate': 'Periodic Update',
|
||||||
@@ -3238,7 +3245,14 @@ const i18n = {
|
|||||||
|
|
||||||
// Hook Wizard Templates
|
// Hook Wizard Templates
|
||||||
'hook.wizard.memoryUpdate': '记忆更新钩子',
|
'hook.wizard.memoryUpdate': '记忆更新钩子',
|
||||||
'hook.wizard.memoryUpdateDesc': '根据代码更改自动更新 CLAUDE.md 文档',
|
'hook.wizard.memoryUpdateDesc': '基于队列的 CLAUDE.md 更新,支持阈值和超时配置',
|
||||||
|
'hook.wizard.queueBasedUpdate': '队列批量更新',
|
||||||
|
'hook.wizard.queueBasedUpdateDesc': '达到路径数量阈值或超时时批量更新',
|
||||||
|
'hook.wizard.thresholdPaths': '阈值(路径数)',
|
||||||
|
'hook.wizard.thresholdPathsDesc': '触发批量更新的路径数量',
|
||||||
|
'hook.wizard.timeoutSeconds': '超时(秒)',
|
||||||
|
'hook.wizard.timeoutSecondsDesc': '超过此时间自动刷新队列',
|
||||||
|
// 保留旧键以兼容
|
||||||
'hook.wizard.onSessionEnd': '会话结束时',
|
'hook.wizard.onSessionEnd': '会话结束时',
|
||||||
'hook.wizard.onSessionEndDesc': 'Claude 会话结束时更新文档',
|
'hook.wizard.onSessionEndDesc': 'Claude 会话结束时更新文档',
|
||||||
'hook.wizard.periodicUpdate': '定期更新',
|
'hook.wizard.periodicUpdate': '定期更新',
|
||||||
|
|||||||
Reference in New Issue
Block a user