carlos / platform Public

fix: demo source review round 1

codex agent, operated by paul@keymail.dev pushed by claude agent, operated by paul@keymail.dev bb38485aed0b16a7168034107abf815123855ba6 parent a54499b
2 files changed, +56 −13
  • internal/demobuild/source.go +1 −1
  • internal/demobuild/source_test.go +55 −12

Intent

Human

<task-notification> <task-id>a3387df551a61d007</task-id> <tool-use-id>toolu_018c3fHx6ra69zFZVBBAKUCL</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/cd1b6de2-ac77-426f-a77d-fc5436969c88/tasks/a3387df551a61d007.output</output-file> <status>completed</status> <summary>Agent "Review Task 2 (spec + quality)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Verdict: READY AFTER FIXES - P2-1: `source.go:207` (`forbiddenFile`) accepts `default.pgo`. `go build` reads that file by default (`-pgo=auto`), so it is a hidden build input that reaches the compiler. Refuse `*.pgo` and add a `default.pgo` case to `TestDemoSourceCannotEscapeLock`. - P2-2: some refusal tests in `source_test.go` would still pass with their guard deleted. These are `sparse` and `nul` (:280-291), the four extension-record cases (:198) and `vendor/x.go` (:241). Each is refused for another reason first: no go.mod, a malformed body, or an empty `.go` file. `vendor/modules.txt` is never tested. Build each case on the valid starter archive with well-formed records so it fails only on the guard it names. Full review: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/agent-start-demo-1/.superpowers/sdd/2026-11-02-agent-start-demo-1-anonymous-apps/task-2-review-r1.md</result> <usage><subagent_tokens>125206</subagent_tokens><tool_uses>19</tool_uses><duration_ms>347090</duration_ms></usage> </task-notification>

diff --git a/internal/demobuild/source.go b/internal/demobuild/source.go
index 5f22c917a..8debef255 100644
--- a/internal/demobuild/source.go
+++ b/internal/demobuild/source.go
@@ -218,7 +218,7 @@ func forbiddenFile(name string, isDir bool) bool {
return false
}
switch strings.ToLower(path.Ext(name)) {
- case ".s", ".syso", ".c", ".h", ".cc", ".cpp", ".cxx", ".m", ".mm", ".f", ".for", ".f90", ".o", ".a", ".swig", ".swigcxx":
+ case ".s", ".syso", ".c", ".h", ".cc", ".cpp", ".cxx", ".m", ".mm", ".f", ".for", ".f90", ".o", ".a", ".swig", ".swigcxx", ".pgo":
return true
}
return false
diff --git a/internal/demobuild/source_test.go b/internal/demobuild/source_test.go
index 4074a3ff3..a4d4d0dbc 100644
--- a/internal/demobuild/source_test.go
+++ b/internal/demobuild/source_test.go
@@ -194,11 +194,27 @@ func TestDemoSourceLimits(t *testing.T) {
}
}
func TestDemoSourceCannotEscapeLock(t *testing.T) {
- for _, kind := range []byte{tar.TypeXHeader, tar.TypeXGlobalHeader, tar.TypeGNULongName, tar.TypeGNULongLink} {
- t.Run(fmt.Sprintf("extension-%c", kind), func(t *testing.T) {
- b := tarBytes(t, starter(t))
- b[156] = kind
- fixHeaderChecksum(b)
+ for _, tc := range []struct {
+ kind byte
+ body string
+ }{
+ {tar.TypeXHeader, "17 path=main2.go\n"},
+ {tar.TypeXGlobalHeader, "16 comment=demo\n"},
+ {tar.TypeGNULongName, "main2.go\x00"},
+ {tar.TypeGNULongLink, "main2.go\x00"},
+ } {
+ t.Run(fmt.Sprintf("extension-%c", tc.kind), func(t *testing.T) {
+ es := starter(t)
+ offset := len(tarBytes(t, es)) - 1024
+ es = append(es, archiveEntry{"extension", tc.body, tar.TypeReg}, archiveEntry{"extra.go", "package main\n", tar.TypeReg})
+ b := tarBytes(t, es)
+ if tc.kind == tar.TypeGNULongName || tc.kind == tar.TypeGNULongLink {
+ copy(b[offset+257:offset+265], "ustar \x00")
+ fixHeaderChecksum(b[offset:])
+ }
+ validate(t, gzipBytes(t, b), true)
+ b[offset+156] = tc.kind
+ fixHeaderChecksum(b[offset:])
validate(t, gzipBytes(t, b), false)
})
}
@@ -238,7 +254,26 @@ func TestDemoSourceCannotEscapeLock(t *testing.T) {
for _, kind := range []byte{tar.TypeSymlink, tar.TypeLink, tar.TypeChar, tar.TypeBlock, tar.TypeFifo} {
t.Run(fmt.Sprintf("type-%c", kind), func(t *testing.T) { validate(t, archive(t, append(starter(t), archiveEntry{"bad", "", kind})), false) })
}
- for _, name := range []string{"go.work", "go.work.sum", "vendor/x.go", "nested/go.mod", "nested/go.sum", "x.syso", "x.s", "x.S", "x.c", "x.h", "x.o", "x.a"} {
+ for _, name := range []string{"default.pgo", "custom.pgo", "assets/custom.pgo"} {
+ t.Run(name, func(t *testing.T) {
+ es := append(starter(t), archiveEntry{name + ".txt", "profile", tar.TypeReg})
+ validate(t, archive(t, es), true)
+ es[len(es)-1].name = name
+ validate(t, archive(t, es), false)
+ })
+ }
+ for _, tc := range []struct{ name, body string }{
+ {"modules.txt", "# amadan.net/rastrillo/rastrillo v0.30.2\n## explicit; go 1.26.10\namadan.net/rastrillo/rastrillo\n"},
+ {"x/x.go", "package x\n"},
+ } {
+ t.Run("vendor/"+tc.name, func(t *testing.T) {
+ es := append(starter(t), archiveEntry{tc.name, tc.body, tar.TypeReg})
+ validate(t, archive(t, es), true)
+ es[len(es)-1].name = "vendor/" + tc.name
+ validate(t, archive(t, es), false)
+ })
+ }
+ for _, name := range []string{"go.work", "go.work.sum", "nested/go.mod", "nested/go.sum", "x.syso", "x.s", "x.S", "x.c", "x.h", "x.o", "x.a"} {
t.Run(name, func(t *testing.T) {
validate(t, archive(t, append(starter(t), archiveEntry{name, "", tar.TypeReg})), false)
})
@@ -278,15 +313,23 @@ func TestDemoSourceCannotEscapeLock(t *testing.T) {
t.Run("tar-truncated", func(t *testing.T) { b := tarBytes(t, starter(t)); validate(t, gzipBytes(t, b[:len(b)-1024]), false) })
t.Run("gzip-checksum", func(t *testing.T) { b := archive(t, starter(t)); b[len(b)-8] ^= 1; validate(t, b, false) })
t.Run("sparse", func(t *testing.T) {
- b := tarBytes(t, []archiveEntry{{"bad", "", tar.TypeReg}})
- b[156] = tar.TypeGNUSparse
- fixHeaderChecksum(b)
+ es := starter(t)
+ offset := len(tarBytes(t, es)) - 1024
+ b := tarBytes(t, append(es, archiveEntry{"asset", "", tar.TypeReg}))
+ copy(b[offset+257:offset+265], "ustar \x00")
+ fixHeaderChecksum(b[offset:])
+ validate(t, gzipBytes(t, b), true)
+ b[offset+156] = tar.TypeGNUSparse
+ fixHeaderChecksum(b[offset:])
validate(t, gzipBytes(t, b), false)
})
t.Run("nul", func(t *testing.T) {
- b := tarBytes(t, []archiveEntry{{"bad", "", tar.TypeReg}})
- copy(b[:100], []byte("a\x00b"))
- fixHeaderChecksum(b)
+ es := starter(t)
+ offset := len(tarBytes(t, es)) - 1024
+ b := tarBytes(t, append(es, archiveEntry{"a", "", tar.TypeReg}))
+ validate(t, gzipBytes(t, b), true)
+ copy(b[offset:offset+100], "a\x00b")
+ fixHeaderChecksum(b[offset:])
validate(t, gzipBytes(t, b), false)
})
}