Distrust repository-local Python interpreters (avoid executing .venv/bin/python) - #142
Distrust repository-local Python interpreters (avoid executing .venv/bin/python)#142tachyon-beep wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f40b5d69a
ℹ️ 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".
| pub fn discover_project_interpreter( | ||
| project_root: &Path, | ||
| _project_root: &Path, | ||
| env: &dyn Fn(&str) -> Option<OsString>, |
There was a problem hiding this comment.
Update the CLI test for removed dotvenv discovery
When no override or activated environment is present, ignoring project_root makes discovery return the unpinned PATH/none result, but analyze_interpreter_change_forces_full_reanalysis in crates/loomweave-cli/tests/analyze.rs still supplies only <project>/.venv/bin/python and asserts that this path is fingerprinted and exported. The verify.yml workspace-wide nextest job runs this test, so the suite will fail on Unix; update the integration scenario to transition between trusted interpreter sources while preserving its re-dispatch coverage.
Useful? React with 👍 / 👎.
| # Keep the project root in the API because this function is mirrored by | ||
| # the host, but never use it to select an executable from the repository. | ||
| _ = project_root |
There was a problem hiding this comment.
Remove the obsolete create-.venv remediation
After this function deliberately stops inspecting the project root, merely creating <project>/.venv cannot resolve interpreter_unpinned; nevertheless, loomweave doctor still tells affected users to “set LOOMWEAVE_PYTHON_INTERPRETER or create .venv,” and the Python README and ADR document the same obsolete rung. Users following that advice remain degraded, so the user-facing remediation and discovery documentation should instead require an explicit override or activated environment.
Useful? React with 👍 / 👎.
|
Closing without merge — the concern is real but the fix is too broad. Why not merge:
What happens instead: the narrow mitigation — skip rung 2 only when |
Motivation
<project_root>/.venv/bin/python) which Pyright may invoke, creating an arbitrary code-execution vector.Description
.venv/bin/pythondiscovery from both the Python plugin and the Rust host so repository-local interpreters are no longer selected; the discovery API keepsproject_rootin the signature but does not inspect the repository for executables. (plugins/python/src/loomweave_plugin_python/interpreter.py,crates/loomweave-core/src/plugin/interpreter.rs).dotvenvinterpreter source and adjust the pinned-classification to treat only explicit overrides and activated environments (VIRTUAL_ENV/CONDA_PREFIX) as pinned. (plugins/python/src/loomweave_plugin_python/interpreter.py,crates/loomweave-core/src/plugin/interpreter.rs).crates/loomweave-core/src/plugin/host.rs)..venvexecutables and symlinks are ignored, update Pyright-session tests to exercise explicit overrides, and update server tests to assert no repository interpreter is advertised. (tests underplugins/python/tests/*and changes tocrates/loomweave-coretests).Testing
python -m pytest -o addopts='' plugins/python/tests/test_interpreter.py -q— passed (test subset exercised and 13 tests passed).cargo test -p loomweave-core plugin::interpreter --lib— passed (8 tests passed).cargo test -p loomweave-core only_language_server_plugins_are_pointed_at_the_project_interpreter --lib— passed (host-side regression passed).ruff/python -m compileall,cargo fmt --all -- --check, andgit diff --checkwere run and passed, and the code was committed asfix(python): distrust repository-local interpreters.test_server.py/test_pyright_session.pycould not be collected in this environment due to missingyamlin the test environment and the plugin venv lackingpytest, which are external-environment limitations and not regressions in the changes.Codex Task