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): inspect implicit merge patches for credentials
MagicLizi16c14eefcf1e
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 3b40ef05fa..1252644328 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@@ -223,6 +223,37 @@ describe('GitCredentialHistory', () => {expect(await provesSafe(history, 'git show blob-tag -- src')).toBe(false);});+ it('keeps consent for implicit merge patches containing credentials', async () => {+ write('.env', 'PRIVATE_FIXTURE=base\n');+ git('add', '.env');+ git('commit', '-q', '--no-gpg-sign', '-m', 'base');+ const baseBranch = git('branch', '--show-current').trim();+ git('checkout', '-q', '-b', 'side');+ write('.env', 'PRIVATE_FIXTURE=side\n');+ git('commit', '-qam', 'side', '--no-gpg-sign');+ git('checkout', '-q', baseBranch);+ write('.env', 'PRIVATE_FIXTURE=main\n');+ git('commit', '-qam', 'main', '--no-gpg-sign');+ expect(spawnSync('git', ['merge', '--no-gpg-sign', 'side'], { cwd: repo }).status).toBe(1);+ write('.env', 'PRIVATE_FIXTURE=resolved\n');+ git('add', '.env');+ git('commit', '-qm', 'resolve merge', '--no-gpg-sign');+ const history = new GitCredentialHistory();+ for (const options of [+ ['--remerge-diff'], ['--dd'], ['--diff-merges', 'remerge'],+ ...['on', 'm', 'first-parent', '1', 'separate', 'combined', 'c', 'dense-combined', 'cc', 'remerge', 'r']+ .map((mode) => ['--diff-merges=' + mode]),+ ]) {+ expect(git('log', ...options, '-1'), options.join(' ')).toContain('PRIVATE_FIXTURE=resolved');+ const command = 'git log ' + options.join(' ') + ' -1';+ expect(await provesSafe(history, command), command).toBe(false);+ await requiresCredentialConfirmation(history, command);+ }+ expect(await provesSafe(history, 'git log --oneline -1')).toBe(true);+ expect(await provesSafe(history, 'git log --diff-merges=off -1')).toBe(true);+ expect(await provesSafe(history, 'git log --diff-merges=none -1')).toBe(true);+ });+it('does not trust path-limited full diffs or commits outside the scanned history', async () => {const history = new GitCredentialHistory();const visible = git('rev-parse', 'HEAD').trim();diff --git a/packages/maker-core/src/agents/shared/auto-review.test.ts b/packages/maker-core/src/agents/shared/auto-review.test.tsindex 0695adf4c8..d3f2b0b732 100644--- a/packages/maker-core/src/agents/shared/auto-review.test.ts+++ b/packages/maker-core/src/agents/shared/auto-review.test.ts@@ -4982,6 +4982,21 @@ describe('shellCommandReadsCredentials — 分享任务的附加选项', () => {}});+ it.each([+ '--remerge-diff', '--remerge-di', '--remerge', '--dd',+ '--diff-merges=remerge', '--diff-merges remerge', '--diff-merges=first-parent', '--diff-merges=on',+ ])(+ 'checks implicit merge patches as sharing content without changing local decisions: %s', (option) => {+ const command = 'git log ' + option + ' -1';+ expect(shellCommandReadsCredentials(command, roots)).toBe(false);+ // The existing general classifier treats the dd token as high impact.+ expect(classifyShellCommand(command, roots)).toBe(option === '--dd' ? 'prompt-each-time' : 'auto-approve');+ const collect = vi.fn(() => true);+ expect(shellCommandReadsCredentials(command, roots, { gitContentRead: collect })).toBe(false);+ expect(collect).toHaveBeenCalledExactlyOnceWith(expect.not.objectContaining({ metadataOnly: true }));+ },+ );+it('checks sharing git show object types even when patch output is suppressed', () => {for (const command of ['git show -s deadbeef', 'git show --name-only deadbeef', 'git show --no-patch']) {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 bf084da1db..0633bb75d8 100644--- a/packages/maker-core/src/agents/shared/auto-review.ts+++ b/packages/maker-core/src/agents/shared/auto-review.ts@@ -6428,7 +6428,19 @@ function shellCommandReadsDotenv(}const probesShowObject = opts.gitContentRead !== undefined && invocation.sub === 'show'&& !gitShowHasOnlySafeObjectPaths(invocation.args);- const readsContent = gitContentReadWithoutPath(invocation.sub, invocation.args) || probesShowObject;+ // Merge-diff modes can imply -p; treat long-option prefixes conservatively+ // too. Sharing probes must not grant the metadata-only exemption.+ // Keep the existing local / same-account classifier unchanged.+ const probesMergePatch = sharesGitCredentialChecks+ && /^(?:log|show|whatchanged)$/.test(invocation.sub)+ && invocation.args.some((arg, index, args) => {+ const name = arg.split('=')[0];+ if (!name.startsWith('--') || name.length <= 2) return false;+ if (['--remerge-diff', '--dd'].some((option) => option.startsWith(name))) return true;+ const mode = arg.includes('=') ? arg.slice(arg.indexOf('=') + 1) : args[index + 1];+ return '--diff-merges'.startsWith(name) && mode !== 'off' && mode !== 'none';+ });+ const readsContent = gitContentReadWithoutPath(invocation.sub, invocation.args) || probesShowObject || probesMergePatch;const probesRuntime = opts.gitContentRead !== undefined&& /^(?:diff|show|log|whatchanged|grep|cat-file|status|blame|ls-files|check-ignore)$/.test(invocation.sub);const checksContent = readsContent || probesRuntime || (sharesGitCredentialChecks