fix(python): preserve explicit virtualenv launchers - #227
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8fe4caea7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| executable ??= | ||
| pathLike && isWithin(root, current.path) ? canonical : current.path; |
There was a problem hiding this comment.
Canonicalize aliased repository launchers
When an explicit path reaches a repository-local launcher through an alias outside the protected root (for example, protectedRoot=/real/repo and /tmp/repo-alias/python, where repo-alias points to that repository), current.path appears outside root even though its parent is repository-controlled. If python initially links to a trusted system interpreter, validation succeeds and this branch returns the mutable repository path; retargeting that link after the probe causes subsequent plugin invocations to execute repository code. Canonicalize the launcher's parent before deciding whether its invocation path is outside the protected root.
Useful? React with 👍 / 👎.
51bb7ca to
b4b68e5
Compare
Fixes #194
Summary
Root cause
The trusted-executable boundary used
realpath()both to validate and to invoke every explicit path. On POSIX, a virtualenv'sbin/pythonis commonly a symlink to the system interpreter. Executing that canonical target bypassed the virtualenv'ssite-packages, so Python 3.10 could no longer import the requiredtomlipackage.Impact
Documented
pythonPath,--python, andPYTHONvalues can point to a Python 3.10 virtualenv without losing its installed packages. PATH sanitization and repository-controlled executable protections remain intact.Validation
pnpm dlx bun test --timeout 30000 ./tests-ts/trusted-executable.test.ts— 5 passed, 1 platform skippnpm exec tsc --noEmitpnpm exec prettier --check src/trusted-executable.ts tests-ts/runtime.test.tsgit diff --check