Skip to content

fix(server-core): keep project file operations inside the project - #384

Open
Exeloo wants to merge 39 commits into
mainfrom
fix/server-core-fs-safety
Open

Exeloo wants to merge 39 commits into
mainfrom
fix/server-core-fs-safety

Conversation

@Exeloo

@Exeloo Exeloo commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Closes #250
Closes #251
Closes #252
Closes #253
Closes #256
Closes #257
Closes #264
Closes #269
Refs #348

Hardens the editor server's file layer. Path checks now run on where a path really leads, and every project file operation stays inside the project and out of nf_modules and .git.

Issue Change
#250 The watcher has an error listener: an unreadable folder logs Could not watch part of <location> instead of ending the server.
#252 A recursive listing skips (and logs) a subfolder it can't read; the requested folder itself is still refused.
#269 A folder zip streams without hashing its files first, and leaves out the trash and nf_modules during the walk.
#264 The nf_modules read-only check runs on the real path, for every write (write, mkdir, rename, copy, delete, restore, trash).
#253 Saving keeps the file's mode (never a setuid or setgid bit) and saves through a link to its checked target.
#256 A hosted gateway project can't be rooted in the clone's .git folder (gatewayProjectRoot).
#251 nanoforge.config paths (dir.*, entry files, out.dir) must stay in the project, and /runtime/ serves only trusted projects' files that lie inside it; runtime.manifest goes through the trust check.
#257 Reveal on macOS is always open -R, so a .app folder is shown, not launched.
PathJail.locate(path, guard?) -> { target, real }   checks run on `real`
├─ fs-service writes: nf_modules guard on the real path     (#264)
├─ write(): temp file next to the real target, mode kept     (#253)
├─ gatewayProjectRoot: .git guard                            (#256)
└─ /runtime/: trusted projects only, file checked by the jail (#251)

Found during the work and fixed here (no issue):

  • fs.copy copies entry by entry and never writes through a link in its destination. Links are copied as links only when they still lead inside the project. A failed copy to a new place removes what it made (this is the part of A folder copy that fails halfway leaves a partial copy #348 done here; a failed copy into an existing folder still keeps what it copied).
  • Changes through the file API run one at a time per project folder.
  • A hosted editor's git checks out committed links as plain files (core.symlinks=false).
  • The editor's own .nanoforge/editor/.gitignore is never written through a link, and trash entries are restored only when they are plain entries outside nf_modules.

Docs: AGENTS.md (hosted sessions, restricted mode, /runtime/, config paths, nf_modules), docs/specs/file-manager.md (links, copy, listing, one change at a time) and dated update notes in ADR 0002 and ADR 0005.

How do you test this PR?

Integration: a scratch branch with every editor branch of this sweep merged passed pnpm build, lint, typecheck, pnpm test --force (1014 passed, 1 skipped) and the full e2e suite with the engine (141/141, Chromium only).

Merge danger

Follow-up issues

Quality gate

Lane Result HEAD covered
Docs Updated: AGENTS.md, docs/specs/file-manager.md, ADR 0002 and 0005 dated notes f412e8a
Correctness Pass after 5 rounds (final review: no Blocking or Important; its minors fixed in f412e8a) 2af144f
Performance Pass (one extra realpath per /runtime/ request, about 25 µs, accepted; copy cost measured above) round 1
Accessibility N/A: no UI -
Security Pass after 5 rounds (final review: no Blocking or Important) 2af144f
Style Pass (dated ADR notes added in 0a1616e; pnpm lint) round 1 (6598720); lint on f412e8a

Last round f412e8a: producer red→green, not re-reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation packages:server-core Related to Server core package

Projects

None yet

1 participant