Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): avoid false credential prompts for development commands

zqchris9860e29b34f6
diff --git a/apps/desktop/src/main/remote-agent/__tests__/credentials.test.ts b/apps/desktop/src/main/remote-agent/__tests__/credentials.test.ts
index 09ee2cfaf1..7b4df6912e 100644
--- a/apps/desktop/src/main/remote-agent/__tests__/credentials.test.ts
+++ b/apps/desktop/src/main/remote-agent/__tests__/credentials.test.ts
@@ -266,3 +266,16 @@ describe('secrets written in the command', () => {
}
});
});
+
+
+describe('long development commands', () => {
+ it('scans beyond the model review budget without treating script length as a credential read', () => {
+ const script = "python3 - <<'PY'\n" + '# ordinary edit\n'.repeat(500)
+ + "p='main.ts'\ns=open(p).read()\nopen(p,'w').write(s.replace('true','false'))\nPY";
+ expect(script.length).toBeGreaterThan(4096);
+ const roots = ['/repo'];
+ expect(isShareCredentialCommand(script + '\nnode --test main.test.mjs', roots)).toBe(false);
+ expect(isShareCredentialCommand(script + '\ncat ~/.ssh/id_rsa', roots)).toBe(true);
+ expect(isShareCredentialCommand(script + '\ncat .env', roots)).toBe(true);
+ });
+});
diff --git a/docs/product-rules/provider-sharing.md b/docs/product-rules/provider-sharing.md
index eddfec8c80..d03518d9dc 100644
--- a/docs/product-rules/provider-sharing.md
+++ b/docs/product-rules/provider-sharing.md
@@ -288,6 +288,8 @@ Desktop「设置 → 模型供应商」的左栏(2026-10-08 用户裁决):
- 命令只能按命令文本识别(脚本里读的、编码后再解开的认不出来),是防误发,不是防恶意;
- 减少误弹(2026-10-12 用户裁决)。**以下几条只用于这张分享任务的确认卡**,本机任务、同账号远程供应商与
自动审查的判定都不变:
+ - 普通编辑脚本不因超过模型审阅的 4096 字符预算就算凭证读取。凭证检查扫描完整命令,
+ 独立限制解析资源;长脚本尾部实际读取密钥时仍要求确认;
- `.env.example` / `.env.sample` / `.env.template` 与公钥 `*.pub` 按惯例不含密钥,不算凭证类文件
(读取、启动时同步都照普通文件);放在凭证目录里(如 `~/.ssh/id_rsa.pub`)时仍算。命令中读取
文件时,执行前按该命令段的实际目录核对原始路径与链接的真实目标;模板、公钥与配置目录里的说明
diff --git a/packages/maker-core/src/agents/shared/auto-review.ts b/packages/maker-core/src/agents/shared/auto-review.ts
index 924da0d8fe..f848e21fa5 100644
--- a/packages/maker-core/src/agents/shared/auto-review.ts
+++ b/packages/maker-core/src/agents/shared/auto-review.ts
@@ -6544,8 +6544,9 @@ export function shellCommandReadsCredentials(
depth = 0,
): boolean {
if (typeof command !== 'string' || command.trim().length === 0) return false;
- // 超长命令解析器不展开扫描,按需要确认处理(与 classifyShellCommand 同样不放过)。
- if (command.length > MAX_AUTO_REVIEW_ACTION_TEXT_CHARS) return true;
+ // 确定性扫描与模型审阅的 4096 字符预算无关。普通长编辑脚本不能仅因长度
+ // 被当作凭证读取;仍扫描完整文本,独立上限用于限制解析资源消耗。
+ if (command.length > 256 * 1024) return true;
if (shellCommandReadsDotenv(command, workspaceRoots, opts, depth)) return true;
const variants = deterministicScanVariants(opts.credentialTextTransform?.(command) ?? command);
return matchesAnyVariant(CREDENTIAL_ALWAYS_ASK_PATTERNS, variants) || fetchesCloudMetadata(variants.quotesOnly);