Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(provider-sharing): keep consent for ripgrep preprocessors
MagicLizi28c0cf90df02
diff --git a/apps/desktop/src/main/remote-agent/executor/__tests__/gitCredentials.git-integration.test.ts b/apps/desktop/src/main/remote-agent/executor/__tests__/gitCredentials.git-integration.test.tsindex 926410970a..61c2c7b1c5 100644--- a/apps/desktop/src/main/remote-agent/executor/__tests__/gitCredentials.git-integration.test.ts+++ b/apps/desktop/src/main/remote-agent/executor/__tests__/gitCredentials.git-integration.test.ts@@ -10,7 +10,7 @@ import path from 'node:path';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import { shareCredentialGitReads } from '../../credentials';+import { isShareCredentialCommand, shareCredentialGitReads } from '../../credentials';import { RemoteExecutor } from '../executor';import { ExecutorGate, type ExecutorAction } from '../gate';import { GitCredentialHistory } from '../gitCredentials';@@ -354,6 +354,34 @@ describe('GitCredentialHistory', () => {await requiresCredentialConfirmation(history, command);});+ it.runIf(process.platform !== 'win32')('keeps consent when ripgrep preprocessors expose a credential outside source files', async () => {+ const history = new GitCredentialHistory();+ const ripgrep = path.resolve(__dirname, '../../../../../../ripgrep-bin', process.platform + '-' + process.arch, 'rg');+ const credential = path.join(root, 'private.env');+ const filter = path.join(root, 'preprocessor');+ fs.writeFileSync(credential, 'PRIVATE_FIXTURE=rg-preprocessor\n');+ fs.writeFileSync(filter, '#!/bin/sh\ncat ' + JSON.stringify(credential) + '\n', { mode: 0o700 });+ for (const args of [+ ['PRIVATE_FIXTURE', '-g', '*.ts', '--pre=' + filter, '.'],+ ['PRIVATE_FIXTURE', '-g', '*.ts', '--pre', filter, '.'],+ ['--no-config', 'PRIVATE_FIXTURE', '-g', '*.ts', '--pre=' + filter, '.'],+ ['-e', '--', '-e', 'PRIVATE_FIXTURE', '-g', '*.ts', '--pre=' + filter, '.'],+ ['PRIVATE_FIXTURE', '-g', '*.ts', '--pre-glob', '*.ts', '--pre=' + filter, '.'],+ ]) {+ expect(execFileSync(ripgrep, args, { cwd: repo, encoding: 'utf8' })).toContain('PRIVATE_FIXTURE=rg-preprocessor');+ const command = 'rg ' + args.map((arg) => JSON.stringify(arg)).join(' ');+ expect(isShareCredentialCommand(command, [repo], { cwd: repo, platform: process.platform }), command).toBe(true);+ await requiresCredentialConfirmation(history, command);+ }+ const plain = spawnSync(ripgrep, ['PRIVATE_FIXTURE', '-g', '*.ts', '.'], { cwd: repo, encoding: 'utf8' });+ expect(plain.status).toBe(1);+ expect(plain.stdout).toBe('');+ expect(plain.stderr).toBe('');+ const workspace = new ExecutorWorkspace({ workingDir: repo });+ const gate = new ExecutorGate(workspace, 'full', Date.now, { confirmCredentials: true });+ expect(gate.authorize({ kind: 'exec', command: "rg PRIVATE_FIXTURE -g '*.ts' .", cwd: repo }).ok).toBe(true);+ });+it('keeps consent when --bare selects a different repository in the same directory', async () => {const history = new GitCredentialHistory();expect(await provesSafe(history, 'git show HEAD')).toBe(true);diff --git a/docs/product-rules/provider-sharing.md b/docs/product-rules/provider-sharing.mdindex 16b73afd58..405c38dab8 100644--- a/docs/product-rules/provider-sharing.md+++ b/docs/product-rules/provider-sharing.md@@ -297,6 +297,9 @@ Desktop「设置 → 模型供应商」的左栏(2026-10-08 用户裁决):宿主设置了 `RIPGREP_CONFIG_PATH`、命令里对它赋值时,也不能只凭源码扩展名豁免。配置可能注入跟随链接或其它扩大读取范围的选项;只在 rg 后第一个参数明确为 `--no-config` 时才继续按其它既有规则核实,不把搜索词、选项取值或 `--` 后的同名文本当成禁用配置的标志;+ rg 命令出现预处理器 `--pre`(含分离、附着参数及可能的选项缩写)时,外部程序可以把本机凭证+ 当成源码内容输出,源码扩展名不能证明结果非敏感,保留确认。无法完整解析的写法同样如此,+ 不靠 `--no-config`、`--no-pre`、空值或限制预处理文件的 `--pre-glob` 抵销已出现的预处理器;- git 查看内容的命令(`git diff`、`git show`、`git log -p`、`git grep`)只看命令文本时按可能读到提交进仓库的凭证处理,执行前先在受邀者电脑上核实,读不到凭证类文件就不弹卡:仓库所有分支、标签、stash 与 reflog 的历史和暂存区里从没有凭证类文件;或命令用 `--` 限定的路径碰不到这些文件;或diff --git a/packages/maker-core/src/agents/shared/auto-review.test.ts b/packages/maker-core/src/agents/shared/auto-review.test.tsindex 56cd3e5e2b..be9275c75a 100644--- a/packages/maker-core/src/agents/shared/auto-review.test.ts+++ b/packages/maker-core/src/agents/shared/auto-review.test.ts@@ -4888,6 +4888,33 @@ describe('shellCommandReadsCredentials — 分享任务的附加选项', () => {})).toBe(true);});+ it('keeps sharing source searches behind consent when ripgrep may run a preprocessor', () => {+ for (const command of [+ "rg token -g '*.ts' --pre=/tmp/filter .",+ "rg --pre /tmp/filter token -g '*.ts' .",+ "rg --no-config token -g '*.ts' --pre=/tmp/filter .",+ "rg token -g '*.ts' --pre=/tmp/filter --pre-glob '*.ts' .",+ "rg token -g '*.ts' --pre=/tmp/filter --no-pre .",+ "rg token -g '*.ts' --pre='' .",+ "rg token -g '*.ts' --pr=/tmp/filter .",+ "rg token -g '*.ts' --p /tmp/filter .",+ "rg -e -- -e token -g '*.ts' --pre=/tmp/filter .",+ "rg token -g '*.ts' --'pre'=/tmp/filter .",+ ]) {+ const localDecision = shellCommandReadsCredentials(command, roots);+ expect(shellCommandReadsCredentials(command, roots, { sourceFileSelectors: false }), command).toBe(localDecision);+ expect(shellCommandReadsCredentials(command, roots, { sourceFileSelectors: true }), command).toBe(true);+ }+ for (const command of [+ "rg token -g '*.ts' .",+ "rg --no-config token -g '*.ts' .",+ "rg token -g '*.ts' --pre-glob '*.ts' .",+ "rg token -g '*.ts' --no-pre .",+ ]) {+ expect(shellCommandReadsCredentials(command, roots, { sourceFileSelectors: true }), command).toBe(false);+ }+ });+it('checks runtime helpers for sharing Git metadata without changing local decisions', () => {for (const command of ['git status', 'git ls-files', 'git diff --name-only', 'git log --oneline']) {expect(shellCommandReadsCredentials(command, roots), command).toBe(false);diff --git a/packages/maker-core/src/agents/shared/auto-review.ts b/packages/maker-core/src/agents/shared/auto-review.tsindex 1e99246df2..494772d048 100644--- a/packages/maker-core/src/agents/shared/auto-review.ts+++ b/packages/maker-core/src/agents/shared/auto-review.ts@@ -5727,6 +5727,13 @@ function searchFollowsSymlinks(bin: string, args: readonly string[]): boolean {return false;}+function ripgrepMayRunPreprocessor(args: readonly string[]): boolean {+ return args.some((token) => {+ const name = token.split('=', 1)[0];+ return name.length > 2 && '--pre'.startsWith(name);+ });+}+function rgSearchesPotentialDotenv(args: readonly string[],selectorCouldMatch: (value: string) => boolean = selectorCouldMatchCredential,@@ -6445,6 +6452,7 @@ function shellCommandReadsDotenv(}if (readsCredentialInput) return true;const args = tokens.slice(1);+ if (opts.sourceFileSelectors && bin === 'rg' && ripgrepMayRunPreprocessor(args)) return true;if (opts.sourceFileSelectors && searchFollowsSymlinks(bin, args)) return true;if (opts.sourceFileSelectors && bin === 'rg'&& (opts.ripgrepConfigActive || /\bRIPGREP_CONFIG_PATH\s*=/i.test(command))