mirror of
https://github.com/Twigpine/zero.git
synced 2026-11-10 13:11:31 -10:00
* feat(sandbox): unify command execution and enforcement * test(sandbox): make platform contracts portable * fix(sandbox): close execution lifecycle races Bound retained interactive output, preserve interruption state, and start workspace observation before process launch. Protect active runtime roots with cross-platform leases, capture transient protected-path creation events, and restore process attributes after PTY fallback. * fix(sandbox): restore strict macOS isolation Remove Seatbelt host-local network allowances after native validation showed localhost filters can reach host interfaces. Track process reap completion so retained sessions cannot signal a stale numeric PID.
37 lines
1.2 KiB
Go
37 lines
1.2 KiB
Go
package sandbox
|
|
|
|
import (
|
|
"context"
|
|
"runtime"
|
|
"testing"
|
|
|
|
"github.com/Gitlawb/zero/internal/execution"
|
|
)
|
|
|
|
func TestEnginePreparesTypedCapturedExecution(t *testing.T) {
|
|
if runtime.GOOS == "windows" {
|
|
t.Skip("uses POSIX shell")
|
|
}
|
|
workspace := t.TempDir()
|
|
engine := NewEngine(EngineOptions{
|
|
WorkspaceRoot: workspace,
|
|
Policy: DefaultPolicy(),
|
|
Backend: Backend{Name: BackendUnavailable, Message: "test backend unavailable"},
|
|
})
|
|
runner := execution.NewRunner(engine)
|
|
result := runner.ExecuteCaptured(context.Background(), execution.CapturedRequest{Request: execution.Request{
|
|
Origin: execution.OriginHook,
|
|
Mode: execution.ModeCaptured,
|
|
Command: execution.Command{Name: "/bin/sh", Args: []string{"-c", "printf adapted"}},
|
|
WorkingDirectory: workspace,
|
|
WorkspaceRoots: []string{workspace},
|
|
Approval: execution.ApprovalContext{PolicyVersion: execution.PolicyVersion},
|
|
}})
|
|
if result.Outcome.Kind != execution.OutcomeSuccess || result.Stdout != "adapted" {
|
|
t.Fatalf("captured result = %#v", result)
|
|
}
|
|
if result.Outcome.Enforcement.Level != string(EnforcementDegraded) {
|
|
t.Fatalf("enforcement = %#v, want degraded", result.Outcome.Enforcement)
|
|
}
|
|
}
|