* 预处理参数
(params: Record<string, any>)
| 68 | * 预处理参数 |
| 69 | */ |
| 70 | protected async preprocessParameters(params: Record<string, any>): Promise<Record<string, any>> { |
| 71 | const { files } = params; |
| 72 | |
| 73 | // 验证文件路径安全性 |
| 74 | if (files) { |
| 75 | const fileList = files.split(/\s+/).filter((f: string) => f.trim()); |
| 76 | for (const file of fileList) { |
| 77 | if (file.includes('..') || file.startsWith('/')) { |
| 78 | throw new Error(`不安全的文件路径: ${file}`); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | if (fileList.length === 0) { |
| 83 | throw new Error('没有指定有效的文件路径'); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | return params; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * 构建 Git add 命令 |