Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(auto-review): pipeline provenance 收窄到路径枚举器,内容生产阶段按不可证处理
Chrisa79e697ac73a
diff --git a/packages/maker-core/src/agents/shared/auto-review.test.ts b/packages/maker-core/src/agents/shared/auto-review.test.tsindex b7966454f3..b19b4cb76b 100644--- a/packages/maker-core/src/agents/shared/auto-review.test.ts+++ b/packages/maker-core/src/agents/shared/auto-review.test.ts@@ -2994,6 +2994,52 @@ describe('参数形式的系统路径写入 / setsid 选项(第三十五批评.toBe('prompt-each-time');});+ it('内容生产阶段的位置实参是"被读的输入",不是"产出的位置"', () => {+ // provenance 早先写成「给了位置实参就拿它当上游位置」。那个泛化对**内容**生产阶段是错的:+ // `Get-Content C:\repo\targets.txt | Remove-Item` 删的是那个文件**里写着的**路径,而判据却断言+ // "上游是 C:\repo\targets.txt、在区内、所以安全"(codex 报)。输出一个错的"安全"比没有这条规则+ // 更糟,所以模型收窄成**只对路径枚举器成立**,其余一概不可证。+ const win = ['C:\\repo'];+ for (const c of [+ 'Get-Content C:\\repo\\targets.txt | Remove-Item',+ 'Get-Content C:\\repo\\targets.txt | Remove-Item -Force',+ 'gc C:\\repo\\targets.txt | Remove-Item', // 别名+ 'cat C:\\repo\\targets.txt | Remove-Item',+ 'type C:\\repo\\targets.txt | Remove-Item',+ 'Get-Content C:\\repo\\t.txt | Where-Object { $_ } | Remove-Item', // 经过滤阶段仍不可证+ 'Import-Csv C:\\repo\\t.csv | Remove-Item',+ 'Select-String -Path C:\\repo\\t.txt -Pattern x | Remove-Item',+ // 源会被销毁的 cmdlet 同样覆盖。+ 'Get-Content C:\\repo\\t.txt | Move-Item -Destination C:\\repo\\x',+ ]) {+ expect(classifyShellCommand(c, win, { platform: 'win32' }), c).toBe('prompt-each-time');+ }++ // 反例一:**路径枚举器**的位置实参确实就是产出的位置 → 区内清理仍是灰区。+ for (const c of [+ 'Get-ChildItem C:\\repo\\build\\* | Remove-Item',+ 'Get-ChildItem C:\\repo\\build | Where-Object Name -eq x | Remove-Item',+ 'Get-ChildItem | Remove-Item', // 没实参 = 枚举当前目录+ 'Get-Item C:\\repo\\a.txt | Remove-Item',+ 'Resolve-Path C:\\repo\\a.txt | Remove-Item',+ ]) {+ expect(classifyShellCommand(c, win, { platform: 'win32' }), c).toBe('prompt');+ }+ // 反例二:枚举受保护位置仍必问(收窄没有削弱原有覆盖)。+ expect(classifyShellCommand('Get-ChildItem C:\\Windows\\System32\\* | Remove-Item', win, { platform: 'win32' }))+ .toBe('prompt-each-time');+ // 反例三:项写在命令行上 / 只读源 / 管道右侧不是写 cmdlet → 不走这条。+ for (const c of [+ 'Get-Content C:\\repo\\a.txt | Set-Content C:\\repo\\b.txt',+ 'Get-Content C:\\repo\\a.txt | Out-File C:\\repo\\b.txt',+ 'Get-Process | Export-Csv C:\\repo\\a.csv',+ 'Get-Content C:\\repo\\t.txt | Copy-Item -Destination C:\\repo\\x', // Copy 不销毁源+ 'Get-Content C:\\repo\\a.txt | Select-String x',+ ]) {+ expect(classifyShellCommand(c, win, { platform: 'win32' }), c).toBe('prompt');+ }+ });+it('curl/wget 在 PowerShell 里是 iwr 别名:-OutFile 与 POSIX -o/-O 取并集', () => {// Windows PowerShell 里 `curl` / `wget` 是 Invoke-WebRequest 的别名,落地参数写成 `-OutFile`,// 而这两个 bin 走的是 POSIX 分支(只认 `-o`/`-O`/`--output`)→ 受保护落地漏掉(codex 报)。diff --git a/packages/maker-core/src/agents/shared/auto-review.ts b/packages/maker-core/src/agents/shared/auto-review.tsindex c25a01e193..4edb7cb8a2 100644--- a/packages/maker-core/src/agents/shared/auto-review.ts+++ b/packages/maker-core/src/agents/shared/auto-review.ts@@ -3510,14 +3510,22 @@ function scopedDestructionNeedsConsent(// 留给下一段用:pipeline 到这里为止,「被传下去的对象来自哪些位置」。必须在下面那个// `continue` 之前赋值,否则改目录的段会把它漏掉。// · 只过滤/排序/挑选的阶段 → provenance 原样传递(它没换来源);- // · 给了位置实参 → 就是这些位置;- // · 没给实参但会枚举路径(`Get-ChildItem`)→ 当前目录;- // · 其余(`ForEach-Object` 等能返回任意对象的)→ `null` = 不可证,由下游 fail closed。+ // · **路径枚举器**(`Get-ChildItem` 一族)→ 它的位置实参就是产出的位置,没给实参则枚举当前目录;+ // · 其余一律 `null` = 不可证,由下游 fail closed。+ //+ // 第三条早先写成「给了位置实参就拿它当 provenance」,那个泛化是**错的** ——+ // 对内容生产阶段来说,位置实参是**被读的输入**、不是产出的位置:+ // `Get-Content C:\repo\targets.txt | Remove-Item` 删的是那个文件**里写着的**路径,而判据却+ // 断言"上游是 C:\repo\targets.txt,在区内,所以安全"(codex 报)。输出一个错的"安全"比没有这条+ // 规则更糟,所以收窄成只对路径枚举器成立;`Get-Content`/`Import-Csv`/`Select-String`/+ // `ForEach-Object` 这些一概落到不可证。if (!POWERSHELL_PIPELINE_PASSTHROUGH.has(bin)) {- const operands = positionalOperands(tokens.slice(1));- upstreamOperands = operands.length > 0- ? operands- : POWERSHELL_PATH_ENUMERATORS.has(bin) ? ['.'] : null;+ if (!POWERSHELL_PATH_ENUMERATORS.has(bin)) {+ upstreamOperands = null;+ } else {+ const operands = positionalOperands(tokens.slice(1));+ upstreamOperands = operands.length > 0 ? operands : ['.'];+ }}const cwdChange = directoryChangeTarget(tokens);