An open-source, faster Devin alternative
TypeScript
Support layered secret stores on snapshot/image forks
Brian Reardon28abbdb870eb
diff --git a/internal/api/sandbox.go b/internal/api/sandbox.goindex 41e5cf74..a87b8b44 100644--- a/internal/api/sandbox.go+++ b/internal/api/sandbox.go@@ -1607,18 +1607,37 @@ func (s *Server) createFromCheckpointCore(c echo.Context, userEnvs map[string]stvar originalCfg types.SandboxConfig_ = json.Unmarshal(cp.SandboxConfig, &originalCfg)- // Secret store resolution:- // 1. Checkpoint already has a store → re-resolve fresh (picks up updated secrets).- // User cannot override it (reject if they try).- // 2. Checkpoint has no store + user supplies one → attach it (fresh secrets on a clean fork).- // 3. Neither → no secrets.- if originalCfg.SecretStore != "" && userSecretStore != "" && originalCfg.SecretStore != userSecretStore {- return nil, http.StatusBadRequest, fmt.Errorf("cannot override inherited secret store %q — fork inherits the snapshot's store", originalCfg.SecretStore)- }- if userSecretStore != "" && originalCfg.SecretStore == "" {- originalCfg.SecretStore = userSecretStore+ // Secret store resolution — supports layering:+ // Resolve the checkpoint's store first (base), then the user's store on top (child).+ // Child secrets win on name collision. Egress allowlists aggregate (union).+ // On a fork-of-fork, the checkpoint's SecretStore already represents its+ // full merged ancestry — just treat it as the base.+ baseStore := originalCfg.SecretStore+ if baseStore != "" {+ if err := s.resolveSecretStoreInto(ctx, orgID, &originalCfg); err != nil {+ return nil, http.StatusBadRequest, err+ }}- if originalCfg.SecretStore != "" {+ if userSecretStore != "" && userSecretStore != baseStore {+ baseEgress := originalCfg.EgressAllowlist+ originalCfg.SecretStore = userSecretStore+ if err := s.resolveSecretStoreInto(ctx, orgID, &originalCfg); err != nil {+ return nil, http.StatusBadRequest, err+ }+ // Aggregate egress: union of base + child+ seen := make(map[string]bool, len(originalCfg.EgressAllowlist))+ for _, h := range originalCfg.EgressAllowlist {+ seen[h] = true+ }+ for _, h := range baseEgress {+ if !seen[h] {+ originalCfg.EgressAllowlist = append(originalCfg.EgressAllowlist, h)+ }+ }+ // Persist: child becomes SecretStore, base recorded for lineage+ originalCfg.BaseSecretStore = baseStore+ } else if userSecretStore != "" {+ // Same store — just re-resolve freshif err := s.resolveSecretStoreInto(ctx, orgID, &originalCfg); err != nil {return nil, http.StatusBadRequest, err}diff --git a/pkg/types/sandbox.go b/pkg/types/sandbox.goindex d0bd6cbe..62c64a93 100644--- a/pkg/types/sandbox.go+++ b/pkg/types/sandbox.go@@ -54,7 +54,13 @@ type SandboxConfig struct {TemplateRootfsKey string `json:"templateRootfsKey,omitempty"`TemplateWorkspaceKey string `json:"templateWorkspaceKey,omitempty"`// SecretStore name — resolves secrets from the named secret store.+ // When layered (base snapshot had a store + fork supplies another),+ // this holds the child (fork-supplied) store. BaseSecretStore holds the parent.SecretStore string `json:"secretStore,omitempty"`+ // BaseSecretStore records the parent snapshot's store when a fork layers+ // a different child store on top. On fork-of-fork, the checkpoint's+ // SecretStore already represents its full merged ancestry.+ BaseSecretStore string `json:"baseSecretStore,omitempty"`// EgressAllowlist restricts outbound HTTPS from the sandbox to these hosts.// Supports exact matches ("api.anthropic.com") and wildcards ("*.openai.com").// Empty = all hosts allowed (no restriction).