fix(conda): exclude transitive dependency binaries from PATH #8543
fix(conda): exclude transitive dependency binaries from PATH #8543
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses the issue of Conda packages installing numerous binaries that can shadow system commands, leading to unexpected behavior. It introduces a Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Greptile SummaryThis PR solves a real usability problem with the conda backend: packages like The core feature works correctly and the PR description's validation confirms it for the target case (postgresql: 106 → 36 binaries). Two edge-case concerns remain:
Confidence Score: 4/5
Last reviewed commit: 70e7167 |
There was a problem hiding this comment.
Code Review
This pull request introduces filter_bins support to the conda backend, a valuable feature for managing binaries from conda packages. However, it also introduces a critical path traversal vulnerability where user-supplied binary names are used to construct filesystem paths without proper sanitization, potentially leading to arbitrary file overwrite or deletion during tool installation. While the implementation includes updates to the installation process and list_bin_paths, there are also suggestions to improve maintainability and efficiency. It is crucial to address the path traversal by validating that all binary names are relative and remain within the intended directories.
I think this is the wrong solution to this problem, we shouldn't put transitive deps on PATH. |
|
Thanks for taking a look at this already @jdx! What do you recommend? |
## Problem
Conda packages often pull in dependencies that install many binaries onto PATH. For example, `conda:postgresql` installs not only `psql` but also hundreds of dependency binaries like `clear`, `reset`, `tput`, `tabs`, and other ncurses utilities that shadow standard system commands. Running `clear` after installing `conda:postgresql` can break your terminal because it picks up the conda-provided ncurses `clear` instead of the system one.
There is currently no way to control which binaries from a conda package are exposed on PATH.
## Solution
Add `filter_bins` support to the conda backend, matching the existing implementation in the GitHub backend. When `filter_bins` is specified, only the listed binaries are symlinked into a `.mise-bins` directory, and `list_bin_paths` returns only that directory instead of the full `bin/` path.
```toml
[tools]
"conda:postgresql" = { version = "latest", filter_bins = "psql,pg_dump,pg_restore,createdb,dropdb" }
```
### Changes
- Added `get_filter_bins()` to parse the `filter_bins` option (supports both generic and platform-specific keys via `lookup_platform_key`)
- Added `create_symlink_bin_dir()` to create a `.mise-bins` directory with symlinks only to the specified binaries
- Hooked into both `install_fresh()` and `install_from_locked()` post-install steps
- Updated `list_bin_paths()` to return only `.mise-bins` when `filter_bins` is set
- Updated conda backend documentation with the new option and the `conda:postgresql` example
1b5f5c0 to
9b3b695
Compare
|
not putting the transitive bins on PATH |
|
Done (vibe-coded) and updated the PR description, PTAL. |
9cc95be to
f27da2a
Compare
f27da2a to
6f69c39
Compare
…ically Instead of requiring users to manually specify filter_bins, the conda backend now automatically exposes only binaries from the main package. Uses rattler link_package return value (Vec<PathsEntry>) to identify which files belong to the main package vs transitive dependencies, then symlinks only the main packages binaries into .mise-bins/. This prevents conda dependencies (e.g. ncurses clear/reset/tput when installing postgresql) from shadowing system commands.
6f69c39 to
0373620
Compare
### 🐛 Bug Fixes - **(conda)** exclude transitive dependency binaries from PATH by @simonepri in [#8543](#8543) ### New Contributors - @simonepri made their first contribution in [#8543](#8543) ## 📦 Aqua Registry Updates #### New Packages (1) - [`stackrox/stackrox/roxctl`](https://github.com/stackrox/stackrox/roxctl) #### Updated Packages (7) - [`dprint/dprint`](https://github.com/dprint/dprint) - [`j178/prek`](https://github.com/j178/prek) - [`jdx/hk`](https://github.com/jdx/hk) - [`jdx/mise`](https://github.com/jdx/mise) - [`jdx/usage`](https://github.com/jdx/usage) - [`mvdan/sh`](https://github.com/mvdan/sh) - [`pnpm/pnpm`](https://github.com/pnpm/pnpm)
Problem
Conda packages pull in dependencies that install many binaries onto PATH. For example,
conda:postgresqlinstalls not onlypsqlbut also 70+ dependency binaries likeclear,reset,tput,tabs(from ncurses),ldapadd(from openldap),kinit(from krb5), etc. that shadow standard system commands.
Solution
Instead of exposing the entire
bin/directory (which contains binaries from allpackages), the conda backend now automatically exposes only binaries from the main
package.
This works by capturing the
Vec<PathsEntry>return value from rattler'slink_package()— which lists every file installed by a specific package — andfiltering for entries under
bin/. Only those are symlinked into.mise-bins/, whichis what gets added to PATH.
find them) but are not on PATH
bin/directory for tools installed before this changeValidation
For the
conda:postgresql:psql,pg_dump, ...clear,reset,tput,ldapadd,kinit,c_rehash, ...psql,pg_dump,createdb,dropdb,initdb,pg_ctl,postgres, ...