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 nested credential checks sharing-only
MagicLizid5e2927b16c9
diff --git a/apps/desktop/src/main/remote-agent/executor/__tests__/executor.test.ts b/apps/desktop/src/main/remote-agent/executor/__tests__/executor.test.tsindex 7eff8a3f3f..3d6a9deb49 100644--- a/apps/desktop/src/main/remote-agent/executor/__tests__/executor.test.ts+++ b/apps/desktop/src/main/remote-agent/executor/__tests__/executor.test.ts@@ -580,6 +580,21 @@ describe('findWindowsGitBash', () => {});describe('shared provider credentials', () => {+ it('preserves same-account command approval while sharing checks nested credential reads', () => {+ const workspace = new ExecutorWorkspace({ workingDir: project });+ const sameAccount = new ExecutorGate(workspace, 'normal');+ const shared = new ExecutorGate(workspace, 'normal', Date.now, { confirmCredentials: true });+ for (const command of [+ "bash -c 'cat .env'",+ "python -c 'open(\".env\").read()'",+ 'echo $(git diff)',+ ]) {+ const action: ExecutorAction = { kind: 'exec', command, cwd: project };+ expect(sameAccount.authorize(action).ok, command).toBe(true);+ expect(shared.authorize(action).ok, command).toBe(false);+ }+ });+function sharedExecutor(mode: ReturnType<typeof executorGateModeFor>,confirm?: (action: ExecutorAction) => Promise<ExecutorConfirmation>,diff --git a/packages/maker-core/src/agents/shared/auto-review.test.ts b/packages/maker-core/src/agents/shared/auto-review.test.tsindex be9275c75a..0695adf4c8 100644--- a/packages/maker-core/src/agents/shared/auto-review.test.ts+++ b/packages/maker-core/src/agents/shared/auto-review.test.ts@@ -4722,6 +4722,19 @@ describe('shellCommandReadsCredentials — 只认凭证那一部分红线', () =// 两个附加选项只供供应商分享的受邀者任务用(apps/desktop/src/main/remote-agent/credentials.ts)。describe('shellCommandReadsCredentials — 分享任务的附加选项', () => {+ it.each([+ "bash -c 'cat .env'",+ "python -c 'open(\".env\").read()'",+ 'echo $(git diff)',+ ])('limits nested credential checks to sharing options: %s', (command) => {+ expect(shellCommandReadsCredentials(command, roots)).toBe(false);+ expect(classifyShellCommand(command, roots)).toBe('prompt');+ expect(shellCommandReadsCredentials(command, roots, {+ gitContentRead: () => true,+ gitConfigRead: () => true,+ })).toBe(true);+ });+it('passes original reader operands, redirects and auxiliary files to the sharing path check', () => {for (const command of ['cat .env.example', 'cat < .env.example', 'grep -f .env.example README.md']) {const checked: string[] = [];diff --git a/packages/maker-core/src/agents/shared/auto-review.ts b/packages/maker-core/src/agents/shared/auto-review.tsindex 494772d048..bf084da1db 100644--- a/packages/maker-core/src/agents/shared/auto-review.ts+++ b/packages/maker-core/src/agents/shared/auto-review.ts@@ -6385,15 +6385,15 @@ function shellCommandReadsDotenv(&& executableName(rawTokens[0] ?? '') !== 'git'&& (hasNestedGitInvocation || nestedCredentialPayloads.size > 0)) return true;- // Recursively inspect code supplied to a shell/interpreter, command substitution, eval/awk,- // or find -exec. Without this, `sh -c 'cat .env'`,- // `python -c 'open(".env")'`, and `echo "$(cat .env)"` could bypass the credential path scan.- for (const payload of nestedCredentialPayloads) {- // Inline programs are not shell argv, so a Python/Node reader such as- // `open(".env")` never reaches the reader-specific path parser. Keep- // credential path patterns visible in these payloads before recursing.- if (inlinePayloadMentionsCredentialPath(opts.fileReadRequiresConsent ? payload : credentialText(payload))) return true;- if (shellCommandReadsCredentials(payload, workspaceRoots, opts, depth + 1)) return true;+ // Only sharing callers request these extra nested checks. Local Auto and+ // same-account remote commands retain their existing classification.+ if (sharesGitCredentialChecks || opts.fileReadRequiresConsent) {+ for (const payload of nestedCredentialPayloads) {+ // Inline programs are not shell argv: keep paths in e.g. Python+ // open(".env") visible before recursively checking shell payloads.+ if (inlinePayloadMentionsCredentialPath(opts.fileReadRequiresConsent ? payload : credentialText(payload))) return true;+ if (shellCommandReadsCredentials(payload, workspaceRoots, opts, depth + 1)) return true;+ }}if (opts.gitConfigRead && (bin === 'git' || bin.startsWith('git-credential'))) {