Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions apps/agent/internal/rpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,15 @@ func (h *Handler) hostExecKill(raw json.RawMessage) (any, error) {
func (h *Handler) ptyStart(raw json.RawMessage, send func(Msg)) (any, error) {
var p struct {
host.ExecParams
SpaceID string `json:"spaceId"`
Cols int `json:"cols"`
Rows int `json:"rows"`
SpaceID string `json:"spaceId"`
AllowHostWorkspace bool `json:"allowHostWorkspace"`
Cols int `json:"cols"`
Rows int `json:"rows"`
}
_ = json.Unmarshal(raw, &p)
if p.SpaceID != "" && !p.AllowHostWorkspace {
return nil, fmt.Errorf("space-scoped host terminals are disabled; migrate the workspace to container mode")
}
root := h.StorageRoot
if p.SpaceID != "" {
root = h.workspace(p.SpaceID)
Expand Down
17 changes: 17 additions & 0 deletions apps/agent/internal/rpc/sandbox_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ func TestSandboxRPCRejectsUnsupportedTransports(t *testing.T) {
}
}

func TestHostPTYRejectsSpaceScopedExecution(t *testing.T) {
t.Setenv("ZAKURA_SANDBOX_ENABLED", "")
h := New("computer", t.TempDir())
result := sandboxCall(t, h, "host.pty.start", map[string]any{"spaceId": "space-a", "command": []string{os.Args[0]}})
if result.Error == "" || !strings.Contains(result.Error, "container mode") {
t.Fatalf("space-scoped host terminal was not refused: %+v", result)
}
if _, err := os.Stat(h.workspace("space-a")); !os.IsNotExist(err) {
t.Fatalf("space-scoped host terminal created a workspace: %v", err)
}
h.mu.Lock()
defer h.mu.Unlock()
if len(h.ptys) != 0 {
t.Fatalf("space-scoped host terminal allocated %d streams", len(h.ptys))
}
}

func TestSandboxRPCRequiresWorkspaceAndAvailableBackend(t *testing.T) {
t.Setenv("ZAKURA_SANDBOX_ENABLED", "")
t.Setenv("ZAKURA_SANDBOX_IMAGE", "")
Expand Down
5 changes: 3 additions & 2 deletions apps/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ it with SQLite defaults (`PUBLIC_BASE_URL=http://localhost:8787`,
`WEB_PUBLIC_URL=http://localhost:3001`). Equivalent manual invocation:

```sh
export ZAKURA_SECRET='replace-with-at-least-32-random-bytes'
export ZAKURA_SECRET="$(openssl rand -hex 32)"
export DATABASE_URL='file:./data/zakura.db'
export DATA_DIR='./data'
export PUBLIC_BASE_URL='http://localhost:8787'
Expand Down Expand Up @@ -78,7 +78,8 @@ flow, race/vet/build, and all native stdio sidecar image builds.
- Set the canonical HTTPS `PUBLIC_BASE_URL` and `WEB_PUBLIC_URL`
- Keep migrations enabled for a single release task, or run them once before
rolling out application replicas
- Terminate TLS at a trusted proxy and preserve the original client IP headers
- Terminate TLS at a trusted proxy, set `TRUSTED_PROXY_CIDRS` to its
comma-separated CIDR allowlist, and have it overwrite `X-Real-IP`
- Use `/api/livez` for liveness and `/api/health` for database readiness
- Back up the database and any runtime workspace volumes together

Expand Down
3 changes: 2 additions & 1 deletion apps/server/integration/frontend_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ func TestPreservedFrontendCoreContracts(t *testing.T) {
t.Fatal(err)
}
var seq atomic.Int64
fixtureNow := time.Now().UTC()
cfg := config.Config{WebURL: "http://web.test", PublicURL: "http://api.test", Edition: "saas", MultiTenant: true}
deps := &appdeps.Dependencies{DB: conn.DB, Gorm: gormDB, Dialect: conn.Dialect, Rebind: conn.Rebind, Clock: func() time.Time { return time.Date(2026, 10, 3, 12, 0, 0, 0, time.UTC) }, NewID: func() string { return fmt.Sprintf("%026d", seq.Add(1)) }, Secret: bytes.Repeat([]byte("z"), 32), PublicURL: cfg.PublicURL, WebURL: cfg.WebURL, DataDir: dataDir, Edition: cfg.Edition, MultiTenant: cfg.MultiTenant, VerifyDomain: func(context.Context, string, string) error { return nil }}
deps := &appdeps.Dependencies{DB: conn.DB, Gorm: gormDB, Dialect: conn.Dialect, Rebind: conn.Rebind, Clock: func() time.Time { return fixtureNow }, NewID: func() string { return fmt.Sprintf("%026d", seq.Add(1)) }, Secret: bytes.Repeat([]byte("z"), 32), PublicURL: cfg.PublicURL, WebURL: cfg.WebURL, DataDir: dataDir, Edition: cfg.Edition, MultiTenant: cfg.MultiTenant, VerifyDomain: func(context.Context, string, string) error { return nil }}
router := platformserver.Router(cfg, deps, slog.New(slog.NewTextHandler(io.Discard, nil)))
srv := httptest.NewServer(router)
defer srv.Close()
Expand Down
6 changes: 4 additions & 2 deletions apps/server/integration/postgres_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ func TestPostgresCoreWorkflow(t *testing.T) {
}

var seq int
fixtureNow := time.Now().UTC()
cfg := config.Config{WebURL: "http://web.test", PublicURL: "http://api.test", Edition: "saas", MultiTenant: true}
deps := &appdeps.Dependencies{
DB: conn.DB, Gorm: gormDB, Dialect: conn.Dialect, Rebind: conn.Rebind,
Clock: func() time.Time { return time.Date(2026, 10, 3, 12, 0, 0, 0, time.UTC) },
Clock: func() time.Time { return fixtureNow },
NewID: func() string { seq++; return fmt.Sprintf("pg-%023d", seq) },
Secret: bytes.Repeat([]byte("p"), 32), PublicURL: cfg.PublicURL,
WebURL: cfg.WebURL, Edition: cfg.Edition, MultiTenant: cfg.MultiTenant,
VerifyDomain: func(context.Context, string, string) error { return nil },
VerifyDomain: func(context.Context, string, string) error { return nil },
ProviderTestPrivate: true,
}
srv := httptest.NewServer(platformserver.Router(cfg, deps, slog.New(slog.NewTextHandler(io.Discard, nil))))
defer srv.Close()
Expand Down
Loading
Loading