-
Notifications
You must be signed in to change notification settings - Fork 104
fix(sandbox): scrub sensitive credentials from sandbox environment #660
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
kevincodex1
merged 12 commits into
Gitlawb:main
from
euxaristia:fix/sandbox-credential-leakage
Jul 14, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
037cee9
fix(windows): retry atomic file renames on Access is denied / Sharing…
euxaristia 7e6840f
test(swarm): add unit tests for rename retry and non-retryable errors
euxaristia bc46ee6
test(swarm): skip TestMailboxRenameRetry on non-Windows platforms
euxaristia faeeba2
fix(sandbox): scrub sensitive provider credentials from sandbox env
euxaristia 0d6e447
refactor(sandbox): unify environment creation and reduce lines of code
euxaristia a4ef569
fix(sandbox): forward workspaceRoot through sandboxEnvironment, gate …
euxaristia c122536
style(sandbox,swarm): remove stray blank lines flagged by gofmt
euxaristia 415aae0
refactor(fsutil): extract shared rename retry helper, derive scrub li…
euxaristia 65eb5fd
fix(sandbox): deny sandboxed reads of cloud credential stores by default
euxaristia 5ae88b5
test(cli): pin HOME in sandbox policy golden test
euxaristia 6960034
fix(sandbox): protect GOOGLE_APPLICATION_CREDENTIALS without a home, …
euxaristia 570b288
fix(sandbox): tighten env-scrub test assertion and add missing secret…
euxaristia 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
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
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,45 @@ | ||
| // Package fsutil provides small filesystem helpers shared across packages. | ||
| package fsutil | ||
|
|
||
| import ( | ||
| "errors" | ||
| "os" | ||
| "runtime" | ||
| "syscall" | ||
| "time" | ||
| ) | ||
|
|
||
| // RenameWithRetry renames src to dst, retrying briefly on Windows when the | ||
| // destination is transiently locked (antivirus scanners, search indexers, or | ||
| // a concurrent reader holding the file open). rename overrides os.Rename so | ||
| // tests can exercise the retry path; pass nil to use os.Rename. | ||
| func RenameWithRetry(src, dst string, rename func(src, dst string) error) error { | ||
| if rename == nil { | ||
| rename = os.Rename | ||
| } | ||
| var err error | ||
| for i := 0; i < 10; i++ { | ||
| err = rename(src, dst) | ||
| if err == nil { | ||
| return nil | ||
| } | ||
| if runtime.GOOS == "windows" { | ||
| if os.IsPermission(err) || isWindowsSharingOrLockViolation(err) { | ||
| time.Sleep(10 * time.Millisecond) | ||
| continue | ||
| } | ||
| } | ||
| break | ||
| } | ||
| return err | ||
| } | ||
|
|
||
| func isWindowsSharingOrLockViolation(err error) bool { | ||
| var errno syscall.Errno | ||
| if errors.As(err, &errno) { | ||
| const ERROR_SHARING_VIOLATION syscall.Errno = 32 | ||
| const ERROR_LOCK_VIOLATION syscall.Errno = 33 | ||
| return errno == ERROR_SHARING_VIOLATION || errno == ERROR_LOCK_VIOLATION | ||
| } | ||
| return false | ||
| } |
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,47 @@ | ||
| package fsutil | ||
|
|
||
| import ( | ||
| "errors" | ||
| "runtime" | ||
| "syscall" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestRenameWithRetryRetriesOnWindows(t *testing.T) { | ||
| if runtime.GOOS != "windows" { | ||
| t.Skip("RenameWithRetry only retries on Windows") | ||
| } | ||
| var attempts int | ||
| err := RenameWithRetry("src", "dst", func(src, dst string) error { | ||
| attempts++ | ||
| switch attempts { | ||
| case 1: | ||
| return syscall.Errno(32) // ERROR_SHARING_VIOLATION | ||
| case 2: | ||
| return syscall.Errno(33) // ERROR_LOCK_VIOLATION | ||
| default: | ||
| return nil | ||
| } | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("expected success after retries, got: %v", err) | ||
| } | ||
| if attempts != 3 { | ||
| t.Errorf("expected 3 attempts, got %d", attempts) | ||
| } | ||
| } | ||
|
|
||
| func TestRenameWithRetryNonRetryableError(t *testing.T) { | ||
| sentinel := errors.New("disk on fire") | ||
| var attempts int | ||
| err := RenameWithRetry("src", "dst", func(src, dst string) error { | ||
| attempts++ | ||
| return sentinel | ||
| }) | ||
| if !errors.Is(err, sentinel) { | ||
| t.Fatalf("expected sentinel error, got: %v", err) | ||
| } | ||
| if attempts != 1 { | ||
| t.Errorf("expected only 1 attempt for non-retryable error, got %d", attempts) | ||
| } | ||
| } |
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
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.