Summary #
Confines POST /import target paths to a required staging directory (GOOSEFOOT_IMPORT_DIR / server.Config.ImportDirectory) and terminates beet import option flags with --:
- Startup canonicalization (
internal/server/server.go,cmd/goosefoot/main.go): RequireImportDirectory(GOOSEFOOT_IMPORT_DIR), resolvingfilepath.Abs+filepath.EvalSymlinksand verifying it is an existing directory once at startup. - Request path confinement (
internal/server/import.go): Require non-empty absolute paths, resolve symlinks, verify the resolved target is a strict subpath ofImportDirectory(rejecting the root staging directory itself,..traversals, sibling prefix directories, escaping symlinks, and non-regular/non-directory special files), pass the canonical resolved path tobeetand post-import hooks, and return sanitized400responses without leaking rawos.PathErrordetails. - CLI option terminator (
internal/beets/runner.go): Pass--before the positional target path in bothDryRunandImport. - Tests & documentation: Add behavioral tests covering startup and request-boundary path validation, and document
GOOSEFOOT_IMPORT_DIRinREADME.md,env.example, andCHANGELOG.md.
Verification #
gofmt -l .go vet ./...go test -race -count=1 ./...