Remove workspace-root configuration and use client run directories
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRepositoryWorkspaceAllowlistAndAudit(t *testing.T) {
|
||||
func TestClientSelectedRepositoryWorkspaceAndAudit(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
store, err := pipeline.Open(filepath.Join(t.TempDir(), "workspace.db"))
|
||||
@@ -32,11 +32,11 @@ func TestRepositoryWorkspaceAllowlistAndAudit(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.workspaceRoots = []string{root}
|
||||
r.execute = func(context.Context, stage.Definition, stage.Values) (stage.Result, error) {
|
||||
return stage.Result{Outcome: "success", Output: stage.Values{"done": true}}, nil
|
||||
}
|
||||
for i, path := range []string{a, b} {
|
||||
os.Symlink(outside, filepath.Join(root, "linked-repo"))
|
||||
for i, path := range []string{a, b, outside, filepath.Join(root, "linked-repo")} {
|
||||
detail, err := r.start(protocol.Message{PipelineID: items[0].ID, Version: 1, RequestKey: path, Input: map[string]any{"prompt": "task"}, Workspace: path})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -51,10 +51,13 @@ func TestRepositoryWorkspaceAllowlistAndAudit(t *testing.T) {
|
||||
t.Fatal("incorrect workspace audit", i, detail)
|
||||
}
|
||||
}
|
||||
os.Symlink(outside, filepath.Join(root, "escape"))
|
||||
for _, path := range []string{outside, filepath.Join(root, "escape"), "relative/repo"} {
|
||||
file := filepath.Join(root, "file")
|
||||
if err := os.WriteFile(file, []byte("not a directory"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, path := range []string{filepath.Join(root, "missing"), file, "relative/repo"} {
|
||||
if _, err := r.start(protocol.Message{PipelineID: items[0].ID, Version: 1, RequestKey: path, Input: map[string]any{"prompt": "task"}, Workspace: path}); err == nil {
|
||||
t.Fatal("unauthorized workspace accepted", path)
|
||||
t.Fatal("invalid run directory accepted", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user