-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(core): confirm read-only git commands when repo config executes programs (#8575) #8645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
17fa6b6
fix(core): confirm read-only git commands when repo config executes p…
yiliang114 d95d980
Merge remote-tracking branch 'origin/main' into fix/8575-git-config-e…
yiliang114 3c46d35
fix(core): close two probe gaps from review of #8575
yiliang114 93c93b6
Merge remote-tracking branch 'origin/main' into fix/8575-git-config-e…
yiliang114 089c987
fix(core): honor Git worktree config semantics
yiliang114 ab63f6b
fix(core): fail closed on opaque git config constructs (#8575)
yiliang114 b1ff1e4
fix(core): track cd in git config probe; close filter/url bypasses (#…
yiliang114 615e225
Merge branch 'main' into fix/8575-git-config-exec-probe
qwen-code-dev-bot 024689f
fix(core): provide getTargetDir in speculation test mocks (#8575)
qwen-code-dev-bot 4200413
fix(core): harden git-config exec probe against cd-tracking bypasses …
qwen-code-dev-bot a6b5174
Merge branch 'main' into fix/8575-git-config-exec-probe
yiliang114 6bf04c4
fix(core): close round-2 review findings for git-config exec probe (#…
qwen-code-dev-bot 6bd8c03
fix(core): flag deprecated dot-form git config sections in exec probe…
qwen-code-dev-bot 874ba25
fix(core): probe core.hooksPath targets in git-config exec probe (#8645)
qwen-code-dev-bot c2fc8b3
fix(core): probe submodule storage configs in git-config exec probe (…
qwen-code-dev-bot bb6000c
fix(core): tighten git config safety checks
yiliang114 c04dd29
fix(core): address verification findings for git-config exec probe (#…
qwen-code-dev-bot 313ef68
refactor(core): reset git config probe to issue scope
yiliang114 4d7193d
Merge remote-tracking branch 'origin/main' into automation/pr-8645-apply
yiliang114 8000faf
fix(core): use Git config semantics for read-only probes
yiliang114 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Read-only Git config safety | ||
|
|
||
| Issue #8575 proves two repository-local configuration paths that turn an otherwise read-only command into program execution: `diff.external` for `git diff`, and `core.fsmonitor` for `git status`. | ||
|
|
||
| The classifier will ask only for those reproduced command/config pairs. It will query effective local and worktree values through `git config --includes --show-scope`, so Git owns config syntax, include handling, precedence, and worktree behavior. Git probe and parse errors fail closed; a cwd that cannot be entered has no config execution path. | ||
|
|
||
| Commands that change directory before the relevant Git command also ask. The classifier will not simulate shell cwd state or resolve `git -C`; the latter is already outside the read-only allowlist. | ||
|
|
||
| Other execution-bearing Git settings are follow-up work only after an independent reproduction identifies the affected read-only subcommand. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Qwen | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { spawnSync } from 'node:child_process'; | ||
| import { statSync } from 'node:fs'; | ||
|
|
||
| interface LocalGitConfigRisk { | ||
| diffExternal: boolean; | ||
| fsmonitor: boolean; | ||
| } | ||
|
|
||
| const NO_RISK: LocalGitConfigRisk = { | ||
| diffExternal: false, | ||
| fsmonitor: false, | ||
| }; | ||
| const PROBE_FAILED: LocalGitConfigRisk = { | ||
| diffExternal: true, | ||
| fsmonitor: true, | ||
| }; | ||
|
|
||
| export function getLocalGitConfigRisk(cwd: string): LocalGitConfigRisk { | ||
| try { | ||
| if (!statSync(cwd).isDirectory()) return NO_RISK; | ||
| } catch { | ||
| return NO_RISK; | ||
| } | ||
|
|
||
| const result = spawnSync( | ||
| 'git', | ||
| [ | ||
| '-C', | ||
| cwd, | ||
| 'config', | ||
| '--includes', | ||
| '--show-scope', | ||
| '--null', | ||
| '--get-regexp', | ||
| '^diff\\.external$|^core\\.fsmonitor$', | ||
| ], | ||
| { | ||
| encoding: 'utf8', | ||
| maxBuffer: 64 * 1024, | ||
| timeout: 1000, | ||
| windowsHide: true, | ||
| }, | ||
| ); | ||
|
|
||
| if (result.status === 1) return NO_RISK; | ||
| if (result.status !== 0 || typeof result.stdout !== 'string') { | ||
| return PROBE_FAILED; | ||
| } | ||
|
|
||
| const effective = new Map<string, { scope: string; value: string }>(); | ||
| const fields = result.stdout.split('\0'); | ||
| for (let i = 0; i + 1 < fields.length; i += 2) { | ||
| const entry = fields[i + 1]!; | ||
| const newline = entry.indexOf('\n'); | ||
| if (newline < 0) return PROBE_FAILED; | ||
| effective.set(entry.slice(0, newline), { | ||
| scope: fields[i]!, | ||
| value: entry.slice(newline + 1), | ||
| }); | ||
| } | ||
|
|
||
| const localValue = (key: string): string | undefined => { | ||
| const entry = effective.get(key); | ||
| return entry && (entry.scope === 'local' || entry.scope === 'worktree') | ||
| ? entry.value.trim() | ||
| : undefined; | ||
| }; | ||
| const diffExternal = localValue('diff.external'); | ||
| const fsmonitor = localValue('core.fsmonitor'); | ||
|
|
||
| return { | ||
| diffExternal: diffExternal !== undefined && diffExternal !== '', | ||
| fsmonitor: | ||
| fsmonitor !== undefined && | ||
| fsmonitor !== '' && | ||
| !/^(?:true|false|yes|no|on|off|0|1)$/i.test(fsmonitor), | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.