fix(wizard-tools): compare canonical paths in resolveEnvPath - #1257
Draft
posthog[bot] wants to merge 2 commits into
Draft
posthog[bot] wants to merge 2 commits into
posthog[bot] wants to merge 2 commits into
Conversation
A working directory with a trailing separator or a relative spelling made every env write look like path traversal, so the run installed the SDK and then aborted without a token. Canonicalise the install dir once in buildSession, compare resolved paths in resolveEnvPath, and capture an analytics event on the rejection branch. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: 264725c8-f2e9-4788-b71c-95b188c7b4cf
Contributor
Author
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Test against a Context Mill branch:
Add Results will be posted here when complete. |
Contributor
Author
|
PostHog Review alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏 |
A file-system or drive root already ends with the separator, so appending one built a `//` prefix that no valid child path starts with. Build the prefix from the root's own trailing separator instead of string arithmetic. The comparison stays case-sensitive, so the guard is not relaxed beyond the root case. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: 264725c8-f2e9-4788-b71c-95b188c7b4cf
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.

Problem
resolveEnvPathdecided "inside the workspace" with a raw string compare againstworkingDirectory, which it never normalised./project/+.envresolves to/project/.env, which does not start with/project//, so a plain.envwas refused as path traversal.resolveProjectDirreturns the install dir untouched for a project at the repo root.inittask, and a required task failure aborts the whole orchestrator run — identify, error tracking, capture, review and dashboard never ran.Changes
resolveEnvPathresolves the working directory before it compares, so a directory that is only spelled differently is the same directory. Real traversal (../, absolute paths) is still refused.buildSessionstorespath.resolve(installDir), so every consumer ofsession.installDirgets a resolved path.env path traversal rejectedwith the requested file name, whether the request was absolute, and the platform. Both tool facades (pi and MCP) call the same helper, so both are covered.Test plan
pnpm vitest run— 2716 tests pass..segment and a relative working directory, and confirms../.envis still refused.pnpm typecheckerror count is unchanged frommain(27 pre-existing).LLM context
Not changed, and worth a separate decision: the report also asks that an env-write failure after code init has landed should not take the rest of the orchestrator down. That is not a path bug — it is the run verdict treating any required task failure as fatal (
orchestrator-runner.ts), and which tasks are required comes from the planner rather than this repo. Makinginitnon-fatal would let a run report success with PostHog code and no token, which is worse than the abort. Left as-is deliberately.Created with PostHog Desktop from this inbox report.
🤖 Generated with Claude Code