Repository navigation
Conversation
…sitories when untrusted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Closes #249
In a folder that is not trusted (restricted mode), git now only reads, and the folder's own git settings can no longer make it run commands. Everything is in
GitService._exec, the one place every git command goes through, so it also covers callers ofGitServiceother than the RPCs.FORBIDDEN: "git needs a trusted folder: trust this folder to change its repository"..gitfile or link,core.worktree, a shared object store, a bare repository). A plain folder still gets git's usual "not a repository" answer.log.showSignature=falseadded to the hosted hardening.Docs:
AGENTS.md(restricted mode) anddocs/docs/editor/git.mdxsay what Git shows in restricted mode and that this check needs Git 2.31 or later.How do you test this PR?
New
describe('an untrusted folder')inpackages/server-core/test/git/git-service.spec.ts, on real temporary repositories that record whether any of their commands ran:git-service.ts: a repository command ran on read, on write and in a submodule, and a remote was reachedThe write test checks all 17 write and remote calls: each is refused, and the repository is left as it was. Tests that change the user's git config run with a temporary
HOME.Commands run from the worktree: server-core vitest (24 files, 138 passed, 0 skipped on 65d1b8f),
pnpm lint,pnpm typecheck(41/41) on 65d1b8f;pnpm buildin round 1. e2e not run (server-only change, covered by unit tests).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
@nanoforge-dev/editor-server-corehas no runtime dependents outside the editor. Merging tomaindeploys the editor app.FORBIDDENuntil the folder is trusted. Git LFS files may show as modified, since no filter runs. A folder whose repository is not inside it shows no Git until trusted. Each command costs about 1.4 ms more (one extra git process).git-service.ts: both edit the hosted hardening. The integration branch kept both: in the hosted hardening'selsebranch, setSERVER_CONFIG. This is security code, so the owners of both PRs must confirm that resolution. The same pair also conflicts ingit-service.spec.ts(the integration branch keeps both suites) and in the restricted-mode line ofAGENTS.md(the integration branch keeps this branch's sentence and puts fs-safety's "(withoutcore.symlinks=false: the user's own checkout keeps its links)" right after "the hosted hardening on").Follow-up issues
Quality gate
AGENTS.md,docs/docs/editor/git.mdx(shared object stores, Git 2.31 or later)pnpm lint)Last round 65d1b8f: producer red→green and a narrow security check, no correctness re-review.