Repository navigation
Harden Git commands used for disposable source downloads - #79067
Conversation
Isolate Git configuration and environment, disable executable hooks and helpers, restrict transports to HTTPS, and preserve host-scoped gh authentication for source download fallbacks. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
This comment has been minimized.
This comment has been minimized.
|
✅ PR Code Quality Reviewer completed the code quality review. PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer is reviewing this pull request using Matt Pocock's engineering skills... |
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
🏗️ Design Decision Gate — ADR RequiredThis PR adds 182 lines in business-logic directories (
Decision inferred: route all Git operations on disposable source-download clones through Next action: review the draft, resolve the
|
Comment MemoryPeek at saved memory (spec-review-history)History |
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Found one blocking correctness regression: disabling all HTTPS redirects prevents downloads from renamed or transferred repositories, which GitHub serves via 301/302. The inline comment describes the failure and a compatible fix. Static review only; tests were not run per review instructions.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~2 AIC · ⊞ 1.5K
Comment /review to run again
| "-c", "core.askPass=", | ||
| "-c", "protocol.allow=never", | ||
| "-c", "protocol.https.allow=always", | ||
| "-c", "http.followRedirects=false", |
There was a problem hiding this comment.
Disabling all HTTP redirects breaks normal GitHub source downloads when a repository has been renamed or transferred: GitHub responds with a 301/302 for the old HTTPS URL, and Git will now fail instead of following it. This regresses the existing fallback paths for those repositories. Please preserve redirect-following for the initial request (for example, http.followRedirects=initial) or otherwise handle trusted HTTPS redirects explicitly, with a regression test.
There was a problem hiding this comment.
d9e6acf enables initial HTTPS redirects and adds a regression test for a renamed repository URL. The Git utility tests passed after updating from main.
Comment MemoryPeek at saved memory (review-history)History |
There was a problem hiding this comment.
🟡 Changes recommended
Source-download isolation remains bypassable through checkout-local Git configuration and inherited GIT_EXEC_PATH overrides, which can select an untrusted transport helper that receives injected credentials.
4 open issues
What changed in this PR
Adds a shared Git command builder to isolate gh-aw’s disposable source downloads from user Git configuration, while leaving development checkouts unchanged.
Changes:
- Adds HTTPS-only transport restrictions and environment-only
ghauthentication. - Migrates workflow downloads and directory-listing fallbacks to the shared builder.
- Adds isolation regression tests and documents the helper’s contract.
| File | Description |
|---|---|
pkg/parser/remote_list_files.go |
Uses isolated commands for listing clones and tree inspection. |
pkg/parser/remote_download_file.go |
Uses isolated commands for archive, clone, and checkout fallbacks. |
pkg/gitutil/source_command.go |
Introduces the shared command builder and credential handling. |
pkg/gitutil/source_command_test.go |
Tests authenticated HTTPS cloning, hostile settings, and transport rejection. |
pkg/gitutil/README.md |
Documents the API, isolation contract, and runtime requirements. |
pkg/cli/download_workflow.go |
Applies the builder throughout workflow-download Git operations. |
Review effort: Max (adaptive)
| } | ||
| cmd := exec.CommandContext(ctx, "git", append(base, args...)...) | ||
| // Do not discover configuration in the caller's checkout. | ||
| cmd.Dir = os.TempDir() |
There was a problem hiding this comment.
d9e6acf moves the default Git working directory outside the surrounding checkout and bounds repository discovery. The regression with TMPDIR inside a checkout passed.
| // Relocatable Git installations need their bundled HTTPS transport. | ||
| if (!strings.HasPrefix(strings.ToUpper(key), "GIT_") || key == "GIT_EXEC_PATH") && key != "SSH_ASKPASS" { | ||
| cmd.Env = append(cmd.Env, value) |
There was a problem hiding this comment.
d9e6acf strips the inherited override and gets the helper directory from Git itself under the isolated environment. The Git utility regression tests passed.
| } | ||
| cmd := exec.CommandContext(ctx, "git", append(base, args...)...) | ||
| // Do not discover configuration in the caller's checkout. | ||
| cmd.Dir = os.TempDir() |
There was a problem hiding this comment.
d9e6acf switches all three clone call sites to the shared absolute temp-directory helper. The relative-TMPDIR regression passed.
| cmd.Env = append(cmd.Env, "GIT_CONFIG_COUNT=1", | ||
| "GIT_CONFIG_KEY_0=http."+remoteURL+".extraheader", | ||
| "GIT_CONFIG_VALUE_0=AUTHORIZATION: basic "+header) |
There was a problem hiding this comment.
d9e6acf retries without the authorization header after authentication rejection. The regression verifies that a public clone succeeds despite a rejected token and that authenticated cloning still works.
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "90da77334be10dd7ecbc4f20ba0c1d308a8c2491",
"kind": "requested",
"schema_version": "1",
"state": "9524c409f3f6535413864cd3f23812a5e165e9b875830745b367cf8a76a3c014",
"work": [
"665d84c56bac3539931948dc9d5f5dd8005b26db5df54987eb2185b5dc60086b",
"6c8e0356dccdd8cda3f32188524e9b2d5b419a82b9e73ae5e7b3542a22f8f4b6",
"78ab93dd8bb3c4d8c34c2b67acce7342aee0240f77df9c8406c5f1e7fecb402c",
"870420d230d31860bdc6dde15cf99c0efd1693eeb96b6e6dfe6eca15e2f75b5d",
"93b3043d9fab679ddd9e45335e87c533ba7f41f276242319a41b3d83d2bad5a8"
],
"workflow": "pr-sous-chef"
}
|
…cloning Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
|
@copilot fix ci failures |
…cloning Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Updated the PR branch from main in |


Source downloads should inspect repository content without executing hooks or commands inherited from the user's Git configuration.
Adds a shared isolated Git command builder and applies it to workflow-download and directory-listing clone fallbacks, including subsequent fetch, checkout, and tree-listing operations. It disables hooks, templates, fsmonitor, credential helpers, interactive prompts, and automatic maintenance; ignores inherited Git configuration overrides; and allows only HTTPS transport without redirects.
Authentication uses host-scoped
ghtokens passed through the child environment, never command arguments or on-disk configuration. The bundled Git HTTPS transport remains available for relocatable installations. Development checkouts are unchanged; these source-download paths intentionally no longer support SSH, file transports, or custom credential helpers.Validation
make agent-report-progressremains blocked by pre-existing custom-linter findings in the touched files: function length, newline splitting, string-index analysis, and an unchecked response-body close. Standard Go lint and impacted tests passed.