Skip to content

Commit d9827b9

Browse files
author
Eric Wheeler
committed
fix: restrict insert_content to append-only
The insert_content tool was intended for appending content only, but the code allowed arbitrary line numbers which could corrupt files. This change enforces that line_number must be 0 (append-only mode) to prevent file corruption. Signed-off-by: Eric Wheeler <[email protected]>
1 parent 0ecc56f commit d9827b9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/core/tools/insertContentTool.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ export async function insertContentTool(
7878
return
7979
}
8080

81+
if (lineNumber !== 0) {
82+
cline.consecutiveMistakeCount++
83+
cline.recordToolError("insert_content")
84+
pushToolResult(formatResponse.toolError("Invalid line number: only append is supported so line must be 0"))
85+
return
86+
}
87+
8188
cline.consecutiveMistakeCount = 0
8289

8390
// Read the file

0 commit comments

Comments
 (0)