diff options
Diffstat (limited to 'packages/core/src/tools/write-file.ts')
| -rw-r--r-- | packages/core/src/tools/write-file.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/packages/core/src/tools/write-file.ts b/packages/core/src/tools/write-file.ts index 2d5e85be..c343cab8 100644 --- a/packages/core/src/tools/write-file.ts +++ b/packages/core/src/tools/write-file.ts @@ -96,6 +96,13 @@ export class WriteFileTool this.client = this.config.getGeminiClient(); } + /** + * Checks if a given path is within the root directory bounds. + * This security check prevents writing files outside the designated root directory. + * + * @param pathToCheck The absolute path to validate + * @returns True if the path is within the root directory, false otherwise + */ private isWithinRoot(pathToCheck: string): boolean { const normalizedPath = path.normalize(pathToCheck); const normalizedRoot = path.normalize(this.config.getTargetDir()); |
