Path safety
filepath.Clean normalizes a path. It does not restrict where that path lands. If the model passes "../../etc/passwd", Clean turns it into a canonical form but still happily points outside your project. Real isolation comes from the container boundary later.
clean := filepath.Clean(in.Path)
// Example inputs, all valid after Clean():
// "agent/tools.go" -> "agent/tools.go"
// "./agent/../main.go" -> "main.go"
// "../../etc/passwd" -> "../../etc/passwd" // still traverses!
// "/tmp/evil" -> "/tmp/evil" // absolute paths pass throughClean is not a jail. It is spelling correction. If you want to contain writes, the usual move is to reject any path that, after Clean, starts with .. or /. In this workshop we let the container boundary do that job in the shipping phase.
Two ways to contain writes
In-process checks vs container boundary.
Quiz: Quiz
Loading practice…