oficina / equipo Public

fix: refuse interpreter gates and pin the go spelling

codex agent, operated by paul@keymail.dev pushed by claude agent, operated by paul@keymail.dev 254c24bc9dbe964f302808a9673577e52ad289ed parent 8ff3974
4 files changed, +106 −2
  • internal/runner/checks/definition.go +2 −2
  • internal/runner/checks/executor.go +2 −0
  • internal/runner/checks/fixes_r2_test.go +73 −0
  • internal/runner/checks/sandbox_test.go +29 −0

CI failed — run details

diff --git a/internal/runner/checks/definition.go b/internal/runner/checks/definition.go
index a42af780..1f2b4d9b 100644
--- a/internal/runner/checks/definition.go
+++ b/internal/runner/checks/definition.go
@@ -418,7 +418,7 @@ func exitMaterialDeclared(d Definition, c Command) bool {
return false
}
switch program {
- case "sh", "bash", "python", "python3", "node":
+ case "sh", "bash":
if len(c.Argv) < 2 || strings.HasPrefix(c.Argv[1], "-") || !frozenArgument(d, c.Dir, c.Argv[1]) {
return false
}
@@ -434,7 +434,7 @@ func exitMaterialDeclared(d Definition, c Command) bool {
}
case "go":
// vet uses its default package. Explicit path operands must be frozen below.
- if len(c.Argv) < 2 || c.Argv[1] != "vet" {
+ if c.Argv[0] != "go" || len(c.Argv) < 2 || c.Argv[1] != "vet" {
return false
}
for _, arg := range c.Argv[2:] {
diff --git a/internal/runner/checks/executor.go b/internal/runner/checks/executor.go
index 24d68701..d0548084 100644
--- a/internal/runner/checks/executor.go
+++ b/internal/runner/checks/executor.go
@@ -274,7 +274,9 @@ func canonicalIsolation(iso team.IsolationSnapshot) team.IsolationSnapshot {
iso.AcknowledgementIDs = slices.Clone(iso.AcknowledgementIDs)
iso.ObservedTuples = slices.Clone(iso.ObservedTuples)
slices.Sort(iso.AcknowledgementIDs)
+ iso.AcknowledgementIDs = slices.Compact(iso.AcknowledgementIDs)
slices.SortFunc(iso.ObservedTuples, func(a, b team.IsolationTuple) int { return bytes.Compare(encode(a), encode(b)) })
+ iso.ObservedTuples = slices.Compact(iso.ObservedTuples)
return iso
}
func (e *Executor) attest(role team.Role, value any, iso team.IsolationSnapshot) {
diff --git a/internal/runner/checks/fixes_r2_test.go b/internal/runner/checks/fixes_r2_test.go
new file mode 100644
index 00000000..95bd4bbd
--- /dev/null
+++ b/internal/runner/checks/fixes_r2_test.go
@@ -0,0 +1,73 @@
+package checks
+
+import (
+ "context"
+ "slices"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/equipo/team"
+)
+
+func TestTrustedExitInterpreterRefused(t *testing.T) {
+ f := newFixture(t)
+ for _, program := range []string{"python", "python3", "node"} {
+ for _, prefix := range []string{"", "/bin/", "/usr/bin/"} {
+ t.Run(prefix+program, func(t *testing.T) {
+ d := f.d
+ d.TrustedPaths = []string{"gate.py", "gate.js"}
+ script := "gate.py"
+ if program == "node" {
+ script = "gate.js"
+ }
+ d.Commands = append(slices.Clone(d.Commands), Command{Argv: []string{prefix + program, script}, Dir: ".", Parser: "exit", TimeoutSeconds: 10})
+ if _, err := ParseDefinition(context.Background(), raw(d), repoID, baseID); err == nil {
+ t.Fatal("interpreter gate accepted with declared entrypoint")
+ }
+ })
+ }
+ }
+}
+
+func TestTrustedExitGoSpelling(t *testing.T) {
+ f := newFixture(t)
+ for _, program := range []string{"go", "/bin/go", "/usr/bin/go"} {
+ t.Run(program, func(t *testing.T) {
+ d := f.d
+ d.Commands = append(slices.Clone(d.Commands), Command{Argv: []string{program, "vet"}, Dir: ".", Parser: "exit", TimeoutSeconds: 10})
+ _, err := ParseDefinition(context.Background(), raw(d), repoID, baseID)
+ if program == "go" {
+ must(t, err)
+ } else if err == nil {
+ t.Fatal("absolute Go spelling bypasses pinned toolchain")
+ }
+ })
+ }
+}
+
+func TestExecutorIsolationDuplicates(t *testing.T) {
+ for _, kind := range []string{"acknowledgements", "tuples"} {
+ t.Run(kind, func(t *testing.T) {
+ f := newFixture(t)
+ iso := team.IsolationSnapshot{Status: "unconfined", RunnerTainted: true, AcknowledgementIDs: []string{"z", "a"}, ObservedTuples: []team.IsolationTuple{{Provider: "codex"}, {Provider: "claude"}}}
+ f.e.cfg.Isolation = func(context.Context) (team.IsolationSnapshot, error) { return iso, nil }
+ result, err := f.e.Reproduce(context.Background(), f.d, f.r, baseID, "")
+ must(t, err)
+ if kind == "acknowledgements" {
+ iso.AcknowledgementIDs = append(iso.AcknowledgementIDs, "z", "a")
+ } else {
+ iso.ObservedTuples = append(iso.ObservedTuples, iso.ObservedTuples...)
+ }
+ before := raw(iso)
+ _, err = f.e.ValidateEvidence(context.Background(), nil, f.e.cfg.Scope, f.e.cfg.Handle, team.ArtifactSpec{Role: team.RoleBaseResult, Payload: raw(result)})
+ if err != nil {
+ t.Fatalf("duplicate %s invalidated unchanged evidence: %v", kind, err)
+ }
+ if string(raw(iso)) != string(before) {
+ t.Fatal("canonicalization changed callback snapshot")
+ }
+ if len(f.e.exposure.AcknowledgementIDs) != 2 || len(f.e.exposure.ObservedTuples) != 2 {
+ t.Fatal("duplicate isolation retained in historical exposure")
+ }
+ })
+ }
+}
diff --git a/internal/runner/checks/sandbox_test.go b/internal/runner/checks/sandbox_test.go
index ba3b41d1..69cc3594 100644
--- a/internal/runner/checks/sandbox_test.go
+++ b/internal/runner/checks/sandbox_test.go
@@ -141,6 +141,15 @@ func testSandboxConfig(t *testing.T, binary, root string) SandboxConfig {
}
func TestCheckSandboxDeniedPathsCache(t *testing.T) {
+ for _, layout := range []string{"user_cache", "fixture_present", "fixture_absent"} {
+ t.Run(layout, func(t *testing.T) {
+ testCheckSandboxCache(t, layout)
+ })
+ }
+}
+
+func testCheckSandboxCache(t *testing.T, layout string) {
+ t.Helper()
root := t.TempDir()
work := filepath.Join(root, "work")
must(t, os.Mkdir(work, 0700))
@@ -148,7 +157,27 @@ func TestCheckSandboxDeniedPathsCache(t *testing.T) {
must(t, err)
s, err := NewCodexSandbox(context.Background(), testSandboxConfig(t, binary, root))
must(t, err)
+ if layout != "user_cache" {
+ s.home = filepath.Join(root, "home")
+ must(t, os.Mkdir(s.home, 0700))
+ if layout == "fixture_present" {
+ must(t, os.MkdirAll(filepath.Join(s.home, ".cache/go-build"), 0700))
+ }
+ }
cache := filepath.Join(s.home, ".cache/go-build")
+ if _, err := os.Stat(cache); os.IsNotExist(err) {
+ missing := cache
+ t.Cleanup(func() {
+ if _, err := os.Stat(missing); !os.IsNotExist(err) {
+ t.Fatal("probe created the missing user cache")
+ }
+ })
+ s.home = filepath.Join(root, "cache-home")
+ cache = filepath.Join(s.home, ".cache/go-build")
+ must(t, os.MkdirAll(cache, 0700))
+ } else {
+ must(t, err)
+ }
probe, err := os.CreateTemp(cache, "equipo-cache-probe-")
must(t, err)
must(t, probe.Close())