From 88c75a06f2687d7648dbd9294c2745516fc0c791 Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Fri, 7 Feb 2025 00:58:20 -0800 Subject: [PATCH] Allow access to files outside cwd --- src/core/ignore/ClineIgnoreController.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/core/ignore/ClineIgnoreController.ts b/src/core/ignore/ClineIgnoreController.ts index 68132145c8..c1eb037d8d 100644 --- a/src/core/ignore/ClineIgnoreController.ts +++ b/src/core/ignore/ClineIgnoreController.ts @@ -100,18 +100,14 @@ export class ClineIgnoreController { try { // Normalize path to be relative to cwd and use forward slashes const absolutePath = path.resolve(this.cwd, filePath) - const relativePath = path.relative(this.cwd, absolutePath).replace(/\\/g, "/") + const relativePath = path.relative(this.cwd, absolutePath).toPosix() - // Block access to paths outside cwd (those starting with '..') - if (relativePath.startsWith("..")) { - return false - } - - // Use ignore library to check if path should be ignored + // Ignore expects paths to be path.relative()'d return !this.ignoreInstance.ignores(relativePath) } catch (error) { - console.error(`Error validating access for ${filePath}:`, error) - return false // Fail closed for security + // console.error(`Error validating access for ${filePath}:`, error) + // Ignore is designed to work with relative file paths, so will throw error for paths outside cwd. We are allowing access to all files outside cwd. + return true } }