From f1d0fb95f4154ed793950ceed7101de02a0514f3 Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Sat, 7 Feb 2026 23:19:33 -0600 Subject: [PATCH] feat(deployment-logs): enhance readValidDirectory function to accept serverId parameter - Updated the readValidDirectory function to include an optional serverId parameter, improving its flexibility for directory validation. - Modified the deployment logs WebSocket server setup to utilize the updated readValidDirectory function, ensuring proper log path validation based on server context. --- apps/dokploy/server/wss/listen-deployment.ts | 3 +-- apps/dokploy/server/wss/utils.ts | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/dokploy/server/wss/listen-deployment.ts b/apps/dokploy/server/wss/listen-deployment.ts index 8aeee2410..99de9949d 100644 --- a/apps/dokploy/server/wss/listen-deployment.ts +++ b/apps/dokploy/server/wss/listen-deployment.ts @@ -34,14 +34,13 @@ export const setupDeploymentLogsWebSocketServer = ( // Generate unique connection ID for tracking const connectionId = `deployment-logs-${Date.now()}-${Math.random().toString(36).substring(7)}`; - if (!logPath) { console.log(`[${connectionId}] logPath no provided`); ws.close(4000, "logPath no provided"); return; } - if (!readValidDirectory(logPath)) { + if (!readValidDirectory(logPath, serverId)) { ws.close(4000, "Invalid log path"); return; } diff --git a/apps/dokploy/server/wss/utils.ts b/apps/dokploy/server/wss/utils.ts index c749fbc51..651269c13 100644 --- a/apps/dokploy/server/wss/utils.ts +++ b/apps/dokploy/server/wss/utils.ts @@ -32,8 +32,11 @@ export const isValidShell = (shell: string): boolean => { return allowedShells.includes(shell); }; -export const readValidDirectory = (directory: string) => { - const { BASE_PATH } = paths(); +export const readValidDirectory = ( + directory: string, + serverId?: string | null, +) => { + const { BASE_PATH } = paths(!!serverId); const resolvedBase = path.resolve(BASE_PATH); const resolvedDir = path.resolve(directory);