summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/write-file.ts
diff options
context:
space:
mode:
authormoon jooho <[email protected]>2025-07-04 09:13:02 +0900
committerGitHub <[email protected]>2025-07-04 00:13:02 +0000
commit8d3fec08e59b100da036b685d20b080203ba3a4c (patch)
treefdfb31c69d8cf15a536e650fb0fdd148d14051ae /packages/core/src/tools/write-file.ts
parent654f8aeb614c3e5129f33d93aa9cfa06d347e3a0 (diff)
Add and improve JSDoc comments for core tool methods (#3128)
Diffstat (limited to 'packages/core/src/tools/write-file.ts')
-rw-r--r--packages/core/src/tools/write-file.ts7
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());