agentbbs/internal/files
Kyle Zengo c8718f25ea
fix: canonicalize root in safeJoin to handle symlinked storage roots (#64)
When the configured storage root (or a system temp dir on macOS where
/var → /private/var) is reached through a symlink, filepath.EvalSymlinks
on a child path resolves to the canonical form, but within() was comparing
against the lexical root — causing valid paths to be rejected with
"files: path escapes its area".

Fix: resolve the root once with EvalSymlinks before the symlink guard
loop, and compare resolved paths against the canonical root. The initial
lexical containment check (line 108) still uses the original root so
that the returned path keeps the caller's expected prefix.

Adds two regression tests:
  - TestSafeJoinSymlinkedRoot: valid file under a symlinked root is accepted
  - TestSafeJoinChildSymlinkEscapeStillBlocked: escaping child symlink is still rejected

Fixes #62

Co-authored-by: Kyle Paul Zengo <kylezengo@mac2012kylezengo.tail2f018b.ts.net>
2026-07-01 01:10:20 -07:00
..
admin.go feat(files): SFTP member storage — private workspaces + shared public area + mgmt TUI 2026-06-23 09:35:04 +00:00
backend.go files: seed a default README.txt into every member's public area 2026-07-01 02:47:27 +00:00
default_readme.txt files: seed a default README.txt into every member's public area 2026-07-01 02:47:27 +00:00
e2e_test.go files: per-user public at ~name/public; home = member directory 2026-06-26 01:21:00 +00:00
files_test.go fix: canonicalize root in safeJoin to handle symlinked storage roots (#64) 2026-07-01 01:10:20 -07:00
fs.go fix: canonicalize root in safeJoin to handle symlinked storage roots (#64) 2026-07-01 01:10:20 -07:00
server.go feat(files): SFTP member storage — private workspaces + shared public area + mgmt TUI 2026-06-23 09:35:04 +00:00
tui.go feat(files): SFTP member storage — private workspaces + shared public area + mgmt TUI 2026-06-23 09:35:04 +00:00
web.go files: /me and /public are two separate per-user areas 2026-06-26 01:36:43 +00:00
web_test.go files: seed a default README.txt into every member's public area 2026-07-01 02:47:27 +00:00