Repository navigation
Avoid process-wide cwd changes in authorization verification - #79737
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
✅ 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 has completed the skills-based review. ✅
|
|
@copilot fix ci failures |
|
✅ 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.
|
|
✅ 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.
|
|
✅ 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.
|
Comment MemoryPeek at saved memory (spec-review-history)History |
There was a problem hiding this comment.
Reviewed the changed authorization verification path and its regression test. I found no actionable correctness, security, or maintainability issues on the changed lines.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
Comment MemoryPeek at saved memory (review-history)History |
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /tdd and /diagnosing-bugs. The production change is correct: the verifier passes gitRoot explicitly, so the remaining os.Getwd fallbacks are not reached here. One inline suggestion: the new test does not fail on the pre-fix code.
📋 Key Themes & Highlights
Key Themes
- Weak regression test: the post-call cwd check passes before and after the fix.
Positive Highlights
- ✅ Removing the process-wide chdir also removes the restore-failure path.
- ✅
go test ./pkg/cli -run TestAuthorizationandgo vet ./pkg/clipass.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~6 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
|
|
||
| after, err := os.Getwd() | ||
| require.NoError(t, err) | ||
| require.Equal(t, before, after) |
There was a problem hiding this comment.
[/tdd] This test also passes on the pre-fix code, so it does not guard the regression. The old deferred chdir restores the directory before the post-call os.Getwd runs, so the check cannot see a mid-verification change.
💡 Suggested test shape
Sample the cwd from a goroutine while verification runs. Pre-fix code failed this check in 3 of 3 runs; the fixed code passed 3 of 3.
var moved atomic.Value
done := make(chan struct{})
sampled := make(chan struct{})
go func() {
defer close(sampled)
for {
select {
case <-done:
return
default:
}
if cwd, err := os.Getwd(); err != nil || cwd != before {
moved.Store(cwd)
return
}
time.Sleep(10 * time.Microsecond)
}
}()
verifyAuthorizationCandidateDirectory(cmd, snapshot, mustParseAuthorizationPolicy(t), result)
close(done)
<-sampled
require.Nil(t, moved.Load(), "process cwd changed during verification")Keep the post-call check too. The sampler is timing-based, but the old chdir window spans the whole verification call, so it is reliably caught.
@copilot please address this.
There was a problem hiding this comment.
🟡 Changes recommended
The test only checks the final working directory, so it misses temporary process-wide changes during verification that can interfere with concurrent work.
1 open issue
What changed in this PR
This PR makes gh-aw authorization verification use the explicit snapshot root instead of changing the process-wide working directory, addressing the interference risk highlighted in #79329.
Changes:
- Remove working-directory save, change, and restore logic.
- Add a test that verifies a snapshot from a separate caller directory and checks the working directory after verification.
| File | Description |
|---|---|
pkg/cli/authorization_policy_test.go |
Tests verification from a separate caller directory. |
pkg/cli/authorization_command.go |
Removes process-wide working-directory changes. |
Review effort: Max (adaptive)
|
|
||
| after, err := os.Getwd() | ||
| require.NoError(t, err) | ||
| require.Equal(t, before, after) |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Authorization verification changed the process working directory to compile an isolated candidate snapshot, risking interference with concurrent work. The snapshot root is already passed explicitly through the verifier and compiler.
os.Getwd/os.Chdirsave-and-restore sequence and use the explicit snapshot root.