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(provider-sharing): scan ambiguous config queries conservatively

MagicLizi8782cd840d9b
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.ts
index d9e51fbaf4..4080798b0d 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
@@ -393,6 +393,18 @@ describe('GitCredentialHistory', () => {
}
});
+ it('does not mistake abbreviated regexp queries for literal config keys', async () => {
+ const history = new GitCredentialHistory();
+ git('config', 'http.extraHeader', 'PRIVATE_FIXTURE=regexp-query');
+ expect(await provesSafe(history, 'git config --get user.name')).toBe(true);
+ for (const option of ['--get-r', '--get-reg']) {
+ expect(git('config', option, '.*')).toContain('PRIVATE_FIXTURE=regexp-query');
+ const command = 'git config ' + option + " '.*'";
+ expect(await provesSafe(history, command), command).toBe(false);
+ await requiresCredentialConfirmation(history, command);
+ }
+ });
+
it('does not exempt a git read after an earlier shell segment may change state', async () => {
const history = new GitCredentialHistory();
expect(await provesSafe(history, 'git add -A && git diff --cached')).toBe(false);
diff --git a/apps/desktop/src/main/remote-agent/executor/gitCredentials.ts b/apps/desktop/src/main/remote-agent/executor/gitCredentials.ts
index 6aaa0914f2..871a12a25d 100644
--- a/apps/desktop/src/main/remote-agent/executor/gitCredentials.ts
+++ b/apps/desktop/src/main/remote-agent/executor/gitCredentials.ts
@@ -438,12 +438,12 @@ async function shownFilesAvoidCredentials(read: GitRead, cwd: string, top: strin
/** 读这一项要打出的 git config 键名(小写);列出全部或认不准键名时为 undefined。 */
function requestedConfigKey(read: GitRead): string | undefined {
- if (read.sub !== 'config' || read.args.some((arg) => /^(?:--list|-l|list|--get-regexp|--get-urlmatch)$/.test(arg))) {
- return undefined;
- }
- // `--type bool core.x` 这类带取值的选项会让位置参数对不上:多于一个就按全部处理。
- const keys = read.args.filter((arg) => !arg.startsWith('-') && arg !== 'get');
- return keys.length === 1 ? keys[0].toLowerCase() : undefined;
+ if (read.sub !== 'config') return undefined;
+ const args = read.args;
+ const key = args.length === 1 ? args[0]
+ : args.length === 2 && ['--get', '--get-all', 'get'].includes(args[0] ?? '') ? args[1]
+ : undefined;
+ return key && !key.startsWith('-') && key.includes('.') ? key.toLowerCase() : undefined;
}
/** 配置项里有密钥:键名或取值里直接写着(带令牌的地址、Authorization 头),或是密码、令牌、http 头这类项。 */
diff --git a/docs/product-rules/provider-sharing.md b/docs/product-rules/provider-sharing.md
index 470c8b6b93..1707ec3ce4 100644
--- a/docs/product-rules/provider-sharing.md
+++ b/docs/product-rules/provider-sharing.md
@@ -308,7 +308,8 @@ Desktop「设置 → 模型供应商」的左栏(2026-10-08 用户裁决):
电脑上生效的 git 配置核实:要打出的那些项里没有密钥(地址里嵌的令牌或密码、`http.extraHeader`、
密码与令牌类配置项)就不弹卡,有才确认;显式切换配置文件、blob 或配置作用域(含附着参数、短选项
组合与长选项缩写)不授予豁免,以免核实的是另一套配置;带取值的选项与单键隐式读取也要核实,
- 不能把选项的取值计入写配置的参数数目而绕过确认;
+ 不能把选项的取值计入写配置的参数数目而绕过确认。只有确定的单键读取才缩小核实范围,查询模式、
+ 缩写或键名认不准时按全部配置核实,不能把正则查询的模式当成单个键名放行;
- 上述 Git 核实仅用于命令段直接调用 PATH 中的裸 `git`,且沿用宿主环境、PATH 各项为绝对目录时。
显式执行文件路径(如 `./git`)、`git.exe`、任何命令包装器(包括 `env`、`command`、`exec`),以及
环境变量的赋值、移除或清空(含 PATH、加载器与 Git 配置来源)都无法与探针证明一致,照旧弹卡;